我的 pandas 数据框如下所示:
VTI VOO VGK IEV
2017-06-20 125.5809 224.3456 55.2675 44.43
2017-06-21 125.1100 223.5591 54.8000 44.05
2017-06-22 124.7800 223.1609 54.8200 44.06
2017-06-23 124.8100 223.1200 54.8400 44.10
我跑
m_price = price.resample('BM', how=lambda x: x[-1])
有效但告诉我:“FutureWarning:不推荐使用 .resample() 新语法是 .resample(...)..apply()"
有人可以帮助我了解新语法吗?谢谢 (Py 3.6.1/ Pandas 0.20.2)
最佳答案
DataFrame.resample()
返回 Resampler
对象。然后你可以使用其中一种方法:http://pandas.pydata.org/pandas-docs/stable/api.html#resampling
在这种情况下,您需要 last()
:
m_price = price.resample('BM').last()
关于python - py/pandas dataframe - 如何将每日收盘价更改为每月收盘价?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44746962/