Using pandas in Python reports an error "module 'pandas' has no attribute 'rolling_mean'", the cause of the problem and the solution

When using the following statement for the dataframe variable df_test in python:

  pd.rolling_mean(df_test['col_name'], ma)

The system reports an error: module 'pandas' has no attribute 'rolling_mean' , the error is reported that pandas has no rolling_mean attribute. The problem is that rolling_mean is a feature of older versions of pandas and can be replaced with a statement like this:

df_test['col_name'].rolling(ma).mean()

The root of the problem is that the rolling_mean() method is no longer supported in the new version of pandas. Alternatively use pip install pandas to install new pandas modules.

Related Posts