'Problem when importing statsmodels.regression.rolling (AttributeError: 'pandas._libs.properties.CachedProperty' object has no attribute 'func')

When I run the below code:

from statsmodels.regression import rolling

I get this error message:

AttributeError Traceback (most recent call last) /var/folders/q9/_s10_9yx6k7gxt3w4t7j0hgw0000gn/T/ipykernel_56663/1581398632.py in ----> 1 from statsmodels.regression import rolling

~/opt/anaconda3/lib/python3.8/site-packages/statsmodels/regression/rolling.py in 456 457 --> 458 class RollingRegressionResults(object): 459 """ 460 Results from rolling regressions

~/opt/anaconda3/lib/python3.8/site-packages/statsmodels/regression/rolling.py in RollingRegressionResults() 514 515 @cache_readonly --> 516 @Appender(RegressionResults.aic.func.doc) 517 def aic(self): 518 return self._wrap(RegressionResults.aic.func(self))

AttributeError: 'pandas._libs.properties.CachedProperty' object has no attribute 'func'

I've never had this problem before and I'm unsure what has gone wrong. I'm running statsmodels version 0.12.2 and Python 3.8.12 on MacOS 11.4. I'm trying to use RollingOLS.

Thanks for your help.

EDIT: Out of curiosity I just replaced all '.func' with '' in this file and this issue no longer exists and the results seem to be accurate. I don't really understand what this did however and since I'm using this in a professional capacity I need to be sure this is correct.



Solution 1:[1]

I can't reproduce this issue with macOS 12.1 - it's likely a problem with your code / system setup.

However, 0.13.2 seems to work.

Solution 2:[2]

I was getting the same error when I was trying to import statsmodels.tsa.arima_model that has been removed & replaced by statsmodels.tsa.arima.model.

The steps I followed to troubleshoot the error are:

  1. Updating pandas using this command: pip install --upgrade pandas --user

  2. Updating statsmodels using this command: pip install --upgrade statsmodels --user

  3. After that I got the below error:

    NotImplementedError: statsmodels.tsa.arima_model.ARMA and statsmodels.tsa.arima_model.ARIMA have been removed in favor of statsmodels.tsa.arima.model.ARIMA (note the . between arima and model) and statsmodels.tsa.SARIMAX.

    statsmodels.tsa.arima.model.ARIMA makes use of the statespace framework and is both well tested and maintained. It also offers alternative specialized parameter estimators.

Then I resolved the error by replacing statsmodels.tsa.arima_model with statsmodels.tsa.arima.model .

Solution 3:[3]

statsmodels.tsa.arima_model.ARMA and statsmodels.tsa.arima_model.ARIMA have been removed in favor of statsmodels.tsa.arima.model.ARIMA (note the . between arima and model) and statsmodels.tsa.SARIMAX.

statsmodels.tsa.arima.model.ARIMA makes use of the statespace framework and is both well tested and maintained. It also offers alternative specialized parameter estimators.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 richardec
Solution 2 Asia Saeed
Solution 3