When trying to resample OHLC dataframe from 1m to hourly i am getting this error:
Dataframe
df.info()
# Column Dtype
--- ------ -----
0 Date_Time datetime64[ns]
1 Open float64
2 High float64
3 Low float64
4 Close float64
df.tail()
Date_Time Open High Low Close
1692259 2014-12-30 20:51:00 2321.0 1213.0 1223.0 2334.0
1692260 2014-12-30 20:52:00 2342.0 2322.0 2332.0 2332.0
1692261 2014-12-30 20:53:00 3421.0 2322.0 2334.0 2123.0
1692262 2014-12-30 20:54:00 2312.0 2332.0 2324.0 2321.0
1692263 2014-12-30 20:55:00 2312.0 1212.0 2343.0 2323.0
...
Attempt 1
df_ohlc = df.resample('60T', on='Date_Time').ohlc()
Error
DataError: No numeric types to aggregate
Attempt 2
Using venky__ recommendation to another post with a similar solution
df_ohlc = df.resample('60T', on='Date_Time').agg({
'Open':'first',
'High':'max',
'Low':'min',
'Close':'last'
})
NaN included but df is clean. How to avoid this?
Open High Low Close
Date_Time
2015-12-26 18:00:00 NaN NaN NaN NaN
2015-12-26 19:00:00 NaN NaN NaN NaN
2015-12-26 20:00:00 NaN NaN NaN NaN
2015-12-26 21:00:00 NaN NaN NaN NaN
2015-12-26 22:00:00 NaN NaN NaN NaN