Appendix: Using Python
This book uses Python. Python is free, available on almost every operating system, and there are thousands of libraries to do almost anything you want. Python is great.
Fun Fact: Python’s name stems from comedy, not reptiles.
Installing Python
- Download and install Python.
- Open your command line or terminal. Type
python --version. This should display the Python version number if the installation was successful.
Install required libraries
In Python, you can import many libraries, making it versatile.

import antigravityYou can install libraries using
pipor an environment manager likeconda. We recommend the latter. Here are some steps to set up your environment.We provide an
environment.ymlfile pinned to the exact package versions this book was built and tested with. Download it, then create and activate the environment with:
conda env create -f environment.yml
conda activate fpppyThat’s it! You should now be ready.
Python examples in this book
We provide Python code for most examples in shaded boxes like this:
# Import required libraries
import pandas as pd
from statsforecast import StatsForecast
from statsforecast.models import AutoETS
from utilsforecast.plotting import plot_series
# Plot one time series
aus_retail = pd.read_csv('data/aus_retail.csv', parse_dates=['Month'])
df = aus_retail.query('`Series ID` == "A3349640L"')
plot_series(df, id_col='Series ID', time_col='Month', target_col='Turnover')
# Produce some forecasts
sf = StatsForecast(
models = [AutoETS(season_length=12)],
freq = 'MS'
)
sf.forecast(df=df, h=24, id_col='Series ID', time_col='Month', target_col='Turnover')These examples assume that you have the necessary Python libraries installed. You can do this via pip, for example
pip install pandasSometimes we assume that the Python code that appears earlier in the same chapter of the book has also been run; so it is best to work through the Python code in the order provided within each chapter.
Getting started with Python
There are many great resources on how to get started with Python. Here are some that we like:
Courses:
Read the docs: