Technical requirements
You can download the Jupyter notebook and necessary datasets from this book’s GitHub repository:
- Jupyter notebook: https://github.com/PacktPublishing/Time-Series-Analysis-with-Python-Cookbook-Second-Edition/blob/main/code/Ch9/Chapter_9.ipynb
- Datasets: https://github.com/PacktPublishing/Time-Series-Analysis-with-Python-Cookbook-Second-Edition/tree/main/datasets/Ch9
This chapter extensively uses pandas 2.3.3 (released September 29, 2025), which is the latest version as of this writing. You can use a more recent version if available.
There are three additional libraries that we will be using:
statsmodels(0.14.5 or higher)Matplotlib(3.10.6 or higher)Scikit-learn(sklearn) (1.7.2 or higher)
You can install these libraries using pip or conda:
Here is the code when using pip:
pip install pandas statsmodels matplotlib scikit-learn
Before diving into the recipes, follow these steps to...