8
當市場數據的工作和日內數據重採樣到每天的時間表如下:
ohlc_dict = {
'Open':'first',
'High':'max',
'Low':'min',
'Last': 'last',
'Volume': 'sum'}
data.resample('1D',how=ohlc_dict).tail().dropna()
Open High Last Low Volume
Timestamp
2016-12-27 163.55 164.18 164.11 163.55 144793.00
2016-12-28 164.18 164.33 164.22 163.89 215288.00
2016-12-29 164.44 164.65 164.49 164.27 245538.00
2016-12-30 164.55 164.56 164.18 164.09 286847.00
這似乎給我的輸出我需要(仍需驗證)...
我得到以下警告:
FutureWarning: how in .resample() is deprecated
the new syntax is .resample(...)..apply(<func>)
問:
這將如何resample
代碼使用新的語法使用apply
當前最佳實踐一致被複制?
我曾嘗試:
剛開始使用數據[「低」]爲例:
def ohlc (df):
return df['Low'].min()
data.resample('1D').dropna().apply(ohlc,axis=1).tail(2)
Timestamp
2016-12-29 164.45
2016-12-30 164.26
dtype: float64
不給我相同的結果和林不知道在哪裏插入apply
。
這裏是data切片以及如果需要對此進行測試:
感謝
尼斯@ayhan: - )我得到和以前一樣的輸出,但警告已經消失。 – ade1e