Preface
Welcome to our online textbook on forecasting for Python 🐍.
This textbook is based on Forecasting: Principles and Practice (3rd ed) and is intended to provide a comprehensive introduction to forecasting methods and to present just enough information about each method for readers to be able to use them sensibly. We don’t attempt to give a thorough discussion of the theoretical details behind each method, although the references at the end of each chapter will hopefully fill in many of those details.
The book is mainly aimed at four audiences:
- People doing forecasting in business without formal training.
- Undergraduate students interested in forecasting.
- MBA students taking a forecasting elective. The original R version is used for masters and third-year undergraduate students at Monash University, Australia.
- Practitioners needing a Python version of Forecasting: Principles and Practice (3rd ed).
For most sections, we only assume that readers are familiar with introductory statistics, and with high-school algebra. There are a couple of sections that also require knowledge of matrices and linear algebra, but these are flagged.
At the end of each chapter we provide a list of “further reading”. These lists suggest textbooks for a more advanced or detailed treatment of the subject. When no suitable textbook exists, we suggest journal articles for more information. To make this textbook easier to follow, we also provide a list of libraries, functions, modules, and classes with links to their documentation.
We use Python throughout the book and intend for students to learn how to forecast with Python. Python is free and available on almost every operating system. It is a great tool for statistical analysis, not just forecasting. See the Using Python appendix for instructions on installing and using Python.
The book is different from other forecasting textbooks in several ways.
- It is free and online, making it accessible to a wide audience.
- It uses Python, which is free, open-source, and extremely powerful software.
- The online version is continuously updated. You don’t have to wait until the next edition for errors to be removed or new methods to be discussed. We will update the book frequently.
- There are dozens of real data examples taken from our own consulting practice. We have worked with hundreds of businesses and organisations helping them with forecasting issues, and this experience has contributed directly to many of the examples given here, as well as guiding our general philosophy of forecasting.
- We emphasise graphical methods more than most forecasters. We use graphs to explore the data, analyse the validity of the models fitted and present the forecasting results.
Changes in the Python edition
The most important change in this edition of the book is that we use Python through the nixtlaverse rather than R. The nixtlaverse is a collection of open-source Python libraries developed by Nixtla that provide a comprehensive, cutting-edge toolkit for time series forecasting. We also included two new chapters: Neural networks (14 Neural networks) and Foundation forecasting models (15 Foundation forecasting models), which are dedicated to recent techniques and developments in neural networks applied to forecasting.
The book covers the fundamental principles and methods of forecasting, demonstrating their application using Python’s powerful ecosystem of libraries, particularly those in the Nixtlaverse. While the core forecasting concepts remain the same, this version shows how to implement various forecasting techniques using Python tools. Readers will learn how to analyze time series data, apply different forecasting methods, and evaluate forecast accuracy, all within the Python environment. This adaptation aims to make the valuable forecasting knowledge from the original book accessible to Python users, while maintaining the practical, example-driven approach that made the R version so popular.
All the datasets used in this book are available on the book’s website under the /data directory. For example, to access aus_tourism.csv, you can navigate to data/aus_tourism.csv.
No doubt we have introduced some mistakes, and we will correct them online as soon as they are spotted. Please continue to let us know about such things.
If you have questions about using the Python libraries discussed in this book, or about forecasting in general, please ask on the OTexts discussion forum.
Happy forecasting! 💙
Rob J Hyndman, George Athanasopoulos, Azul Garza, Cristian Challu, Max Mergenthaler Canseco, and Kin G Olivares
May 2025
Acknowledgements
The Nixtla coauthors thank José Morales, Marco Peixeiro, Mariana Menchero, Olivier Sprangers PhD, Tracy Teal PhD, and Yibei Hu for their help and contributions. Additionally, we would like to thank all the great open source contributors that have made the Nixtlaverse possible. This book would not have been possible without their valuable contributions.
To cite the online version of this book, please use the following:
Hyndman, R.J., Athanasopoulos, G., Garza, A., Challu, C., Mergenthaler, M., & Olivares, K.G. (2024). Forecasting: Principles and Practice, the Pythonic Way. OTexts: Melbourne, Australia. Available at: OTexts.com/fpppy. Accessed on <current date>.
This online version of the book was last updated on 28 May 2025.