我有这样的数据
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
最佳答案
我认为这意味着您的出价
数据类型不正确。
当您执行dfmxn.dtypes
时,如果您看到Bid
的object
,则需要像这样进行转换:
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
关于python - Pandas 重新采样 OHLC,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37382270/