datasetsforecast

raw JSON →
1.0.1 verified Fri May 01 auth: no python

A Python library providing popular time series forecasting datasets (M3, M4, M5, etc.) with easy loading, splitting, and preprocessing. Current version 1.0.1, released June 2025. Maintained by Nixtla, with monthly releases.

pip install datasetsforecast
error ModuleNotFoundError: No module named 'datasetsforecast.losses'
cause The 'losses' module was removed in v1.0.0 as a breaking change.
fix
Remove any import of datasetsforecast.losses. Use another metrics library or compute metrics manually.
error AttributeError: module 'datasetsforecast' has no attribute 'M4'
cause M4 is not exported at the top level; it's in `datasetsforecast.m4`.
fix
Change the import to from datasetsforecast.m4 import M4.
error requests.exceptions.HTTPError: 404 Client Error: Not Found for url: https://zenodo.org/record/...
cause Outdated dataset download URL, fixed in v1.0.1 for M3 and other datasets.
fix
Upgrade to datasetsforecast>=1.0.1: pip install --upgrade datasetsforecast.
breaking In v1.0.0, the `losses` and `evaluation` modules were removed. Any imports from `datasetsforecast.losses` or `datasetsforecast.evaluation` will fail.
fix Remove imports of `losses` and `evaluation`. Use alternative libraries like `numpy` or `scikit-learn` for metrics.
gotcha Dataset classes (M3, M4, M5, etc.) are not directly importable from the top-level `datasetsforecast` package. You must import from the submodule (e.g., `from datasetsforecast.m4 import M4`).
fix Use correct submodule path as shown in the imports section.
gotcha The `M3` dataset download URL changed in v1.0.1. If you're on an older version, you may get a 404 error. Upgrade to >=1.0.1.
fix Run `pip install datasetsforecast>=1.0.1`.
conda install -c conda-forge datasetsforecast

Load the M4 yearly dataset and preview the training set.

from datasetsforecast.m4 import M4
dataset = M4.load('Yearly')
print(dataset['train'].head())