Python 属性错误:模块';熊猫';没有属性';滚动';

Python 属性错误:模块';熊猫';没有属性';滚动';,python,pandas,data-analysis,Python,Pandas,Data Analysis,我将假设标题错误应该是AttributeError:module'pandas'没有属性'rolling\u mean',因为我认为它已被弃用,然后被删除。此外,pd.rolling不在提供的代码中。在这种情况下,您应该使用滚动。假设timeseries是pd.Series: from statsmodels.tsa.stattools import adfuller def test_stationarity(timeseries): #Determing rolling stati

我将假设标题错误应该是
AttributeError:module'pandas'没有属性'rolling\u mean'
,因为我认为它已被弃用,然后被删除。此外,
pd.rolling
不在提供的代码中。在这种情况下,您应该使用
滚动
。假设
timeseries
pd.Series

from statsmodels.tsa.stattools import adfuller
def test_stationarity(timeseries):

    #Determing rolling statistics
    rolmean = pd.rolling_mean(timeseries, window=24) # 24 hours on each day
    rolstd = pd.rolling_std(timeseries, window=24)

    #Plot rolling statistics:
    orig = plt.plot(timeseries, color='blue',label='Original')
    mean = plt.plot(rolmean, color='red', label='Rolling Mean')
    std = plt.plot(rolstd, color='black', label = 'Rolling Std')
    plt.legend(loc='best')
    plt.title('Rolling Mean & Standard Deviation')
    plt.show(block=False)

    #Perform Dickey-Fuller test:
    print ('Results of Dickey-Fuller Test:')
    dftest = adfuller(timeseries, autolag='AIC')
    dfoutput = pd.Series(dftest[0:4], index=['Test Statistic','p-value','#Lags Used','Number of Observations Used'])
    for key,value in dftest[4].items():
        dfoutput['Critical Value (%s)'%key] = value
    print (dfoutput)

from matplotlib.pylab import rcParams
rcParams['figure.figsize'] = 20,10

test_stationarity(train_original['Count'])

尝试执行conda安装-c conda forge statsmodels,根据前面的语法,笔记本无法识别adfuller。然后尝试pip卸载pandas并执行pip安装pandas。对于类似的情况,可以尝试链接中的说明

能否请您详细说明问题所在以及迄今为止您尝试了什么?可能想查看如何提出一个好问题常见问题解答:您使用的是什么版本的pandas?pd.\uu version\uuuuuuuuuuuu out[3]:“0.23.0”您为什么从statsmodels.tsa.stattools导入adfuller,如果你没有使用它?@MarlonHenriqueTeixeira可能是因为我复制
def
行时的懒惰。我将删除它以避免混淆
def test_stationarity(timeseries):

    #Determing rolling statistics
    rolmean = timeseries.rolling(window=24).mean() # 24 hours on each day
    rolstd = timeseries.rolling(window=24).std()
from statsmodels.tsa.stattools import adfuller
def test_stationarity(timeseries):
    #determine rolling statistics
    rolmean = pd.Series(timeseries).rolling(window=24).mean()#24 hours on each day
    rolstd = pd.Series(timeseries).rolling(window=24).std()
    #plot rolling statistics
    orig = plt.plot(timeseries,color = 'blue',label='original')
    mean = plt.plot(rolmean,color = 'red',label = 'rolling mean')
    std = plt.plot(rolstd,color = 'black',label = 'rolling std')
    plt.legend(loc = 'best')
    plt.title('rolling mean and standard deviation')
    plt.show(block = False)
    #perform dickey fuller test
    print('result of dickey fuller test:')
    dftest = adfuller(timeseries,autolag = 'AIC')
    dfoutput = pd.Series(dftest[0:4],index = ['Test statistics', 'p-value', '#lags used', 'number of observation used'])
    for key,value in dftest[4].items():
        dfoutput['critical value (%s)'%key] = value
    print(dfoutput)

from matplotlib.pylab import rcParams
rcParams['figure.figsize'] = 20,10
test_stationarity(train_original['Count'])