Explorar o código

Prune Outliers by default to make plotting easier to understand.

KeyMasterOfGozer hai 10 meses
pai
achega
69990bfc86
Modificáronse 1 ficheiros con 5 adicións e 1 borrados
  1. 5 1
      db.py

+ 5 - 1
db.py

@@ -1,11 +1,13 @@
 from tinydb import TinyDB, Query
 import pandas as pd
+import numpy as np
+from scipy import stats
 import matplotlib.pyplot as plt
 from datetime import datetime,date
 MarketDB = TinyDB('market.json')
 PlayerDB = TinyDB('player.json')
 
-def getDF(card=None,aDate=None):
+def getDF(card=None,aDate=None,pruneOutliers=True):
     """
         Supply either a card identifier or a date for filter by.
 
@@ -32,6 +34,8 @@ def getDF(card=None,aDate=None):
         else:
             d=MarketDB.search(Query()['date']==aDate)
     df=pd.DataFrame(d)
+    if pruneOutliers:
+        df=df[np.abs(stats.zscore(df['cost'])) < 1.5]
     df.sort_values(by=['card-num','date'], ascending=[True,True], inplace=True)
     return df.round({'cost':2,'cost-min':0,'cost-max':0})