AttributeError: 'module' object has no attribute 'rolling'

xiaoxiao2022-06-03  19

原因:python版本更新

解决:

数据源:

import pandas as pd Backend TkAgg is interactive backend. Turning interactive mode on. import numpy as np from pandas import DataFrame,Series close_px_all = pd.read_csv('D:\python\DataAnalysis\data\stock_px.csv', parse_dates=True, index_col=0) close_px = close_px_all[['AAPL', 'MSFT', 'XOM']] close_px = close_px.resample('B').ffill() close_px.AAPL.plot() <matplotlib.axes._subplots.AxesSubplot object at 0x0000000011013860>

原报错代码:

pd.rolling().mean(close_px.AAPL,250).plot()

改为:

close_px['AAPL'].rolling(250).mean().plot()

 

小结:

这是第一次在网上找不到自己的bug解决方案,还是去外国网站解决的,努力,遇见更好的自己

转载请注明原文地址: https://www.6miu.com/read-4915055.html

最新回复(0)