I believe statsmodels is part of the standard environment form Python in Excel. I am trying to use Python in Excel to forecast time series data using the SARIMAX model from the statsmodels library.
When I use the statement:
from statsmodels.tsa.statespace.sarimax import SARIMAX
to import SARIMAX, I get the error:
AttributeError: module ‘statsmodels.tsa.statespace’ has no attribute ‘SARIMAX’
Is SARIMAX not available in the Python in Excel environment?
Hi @jbraun
I tried to replicate your issue on my end, but it seems everything seems to be working on my end.
This is the code that I used to import SARIMAX in my Python cell:
from statsmodels.tsa.statespace.sarimax import SARIMAX
SARIMAX
This worked perfectly fine, and I correctly see type as result of my cell, as in fact I am returning the Python class itself.
Now, about your error:
I noticed though your import statement correctly imports SARIMAX from the sarimax module, but the AttributeError mentions onlystatsmodels.tsa.statespace.
So, can it be that you are seeing that error in the Diagnostic panel from a previous execution of your code with the wrong import statement?
Please bear in mind that the Diagnostic panel logs of all the exceptions and errors that occur throughout all the executions of your code. And more importantly, these logs are not flushed out, until you manually clear the panel.
The other guess I had was that perhaps you were on “Manual Mode” (Automatic Execution off) and that you’re actually running an old and not-up-to-date Python cell ?