我有这样的数据
bid
time
2016-05-22 21:05:57.651 18.32280
2016-05-22 21:06:58.005 18.32280
2016-05-22 21:17:30.739 18.31820
2016-05-22 21:17:34.121 18.31820
...
当我尝试
df_ohlcMXN = dfmxn.resample('5Min').ohlc()
我得到一个错误
pandas.core.base.DataError: No numeric types to aggregate
我认为这意味着您bid
的数据类型不正确。
当你这样做dfmxn.dtypes
,如果你看到object
的Bid
,它需要被转换这样的:
dfmxn['Bid'] = dfmxn['Bid'].astype('float64')
dfmxn.resample('5Min').ohlc()
为我制作了这个:
Bid
open high low close
Time
2016-05-22 21:05:00 18.3228 18.3228 18.3228 18.3228
2016-05-22 21:10:00 NaN NaN NaN NaN
2016-05-22 21:15:00 18.3182 18.3182 18.3182 18.3182
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句