我有一个 1 分钟柱 OHLC 价格 CSV 文件,我正在尝试将其重新采样为 15 分钟柱。我正在使用的代码来自于此link http://sacbnctrading.blogspot.in/2016/10/convert-1m-ohlc-data-into-other.html,并且如下:
ohlc_dict = {'open':'first', 'high':'max', 'low':'min', 'close': 'last'}
price15m = df.resample('15Min', how=ohlc_dict, closed='right').dropna(how='any')
我收到了预期的重新采样数据帧,但也出现了此警告:
FutureWarning: how in .resample() is deprecated
the new syntax is .resample(...)..apply(<func>)
ohlc_dict = {'open':'first', 'high':'max', 'low':'min', 'close': 'last'}
建议使用此语法,但我不确定如何:
the new syntax is .resample(...)..apply(<func>)
有人能指出我正确的方向吗?非常感谢!
您可以使用Resampler.agg http://pandas.pydata.org/pandas-docs/stable/generated/pandas.core.resample.Resampler.aggregate.html:
price15m = df.resample('15Min', closed='right').agg(ohlc_dict).dropna(how='any')
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)