Search code examples
jupyter-notebookstatsmodelsloess

ImportError: cannot import name 'STL' from 'statsmodels.tsa.seasonal'


I have this issue now, I cannot import STL from statsmodels. I've tried to uninstall statsmodels as it was recommended somewhere with a similar issue but it is not possible, at least the way I do it: !pip uninstall statsmodels - NOT working.


Solution

  • It seems that the STL function from statsmodels is not included in the latest stable version of the library (0.10.2) but is in the dev version (0.11.0dev0).

    You can build and install this specific version with this command: pip install git+https://github.com/statsmodels/statsmodels.git

    For this you may need a c compiler if you don't already have one, everything is explained here: https://www.statsmodels.org/dev/install.html#installation-from-source

    I've also found this package that seems promising: https://github.com/jrmontag/STLDecompose