1 回答

TA貢獻(xiàn)1887條經(jīng)驗(yàn) 獲得超5個(gè)贊
您應(yīng)該offset在方法中使用參數(shù)pd.resample而不是loffset:
df2 = df.resample('1H', offset='30Min').agg({'open': 'first',
'high': 'max',
'low': 'min',
'close': 'last',
'volume': 'sum'})
順便說(shuō)一句,loffset自 1.1.0 版以來(lái)已棄用??赡苄枰滦茇?。
結(jié)果df2:
open high low close volume
t
2020-08-24 09:30:00 514.7900 515.1400 500.000 502.8899 18775884
2020-08-24 10:30:00 502.8190 504.4000 495.745 501.3500 10385806
2020-08-24 11:30:00 501.3400 514.7809 501.250 507.7000 7159132
2020-08-24 12:30:00 507.7000 508.0000 504.000 505.1700 5238818
2020-08-24 13:30:00 505.1707 507.0800 503.120 504.1742 4435539
2020-08-24 14:30:00 504.1800 514.6800 498.620 503.2265 6647980
2020-08-24 15:30:00 503.2330 504.5150 501.546 503.7900 4239235
添加回答
舉報(bào)