ソースを参照

Prune Outliers by default to make plotting easier to understand.

KeyMasterOfGozer 10 ヶ月 前
コミット
69990bfc86
1 ファイル変更5 行追加1 行削除
  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})