gpt4 book ai didi

python - Pandas 重采样 FutureWarning

转载 作者:太空宇宙 更新时间:2023-11-03 10:52:04 25 4
gpt4 key购买 nike

我有一个 1 分钟柱线 OHLC 价格 CSV 文件,我正在尝试将其重新采样为 15 分钟柱线。我使用的代码来自这个 link , 如下:

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 :

price15m = df.resample('15Min', closed='right').agg(ohlc_dict).dropna(how='any')

关于python - Pandas 重采样 FutureWarning,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/48322421/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com