Python Forecasting for Beginners: A Complete Step-by-Step Guide
Forecast a time series in Python without the textbook. A clear, hands-on walkthrough using pandas, statsmodels, and Prophet — with the code you can copy.
June 17, 2026

Forecasting in Python sounds intimidating — autoregressive models, seasonality decomposition, MAPE, RMSE — and most tutorials make it worse by jumping straight into the maths. You don't need any of that to ship a useful first forecast this week.
What you need is: a time series, four lines of pandas, one of four forecasting libraries, and a metric to tell you whether the forecast is any good. This guide walks through that, end-to-end, in plain language.
TL;DR — Python forecasting in four steps
Load your time series into pandas with a datetime index. Visualise it to spot trend and seasonality. Fit a baseline (naïve or exponential smoothing) and a slightly fancier model (Prophet, statsmodels' ETS, or a tree-based model with skforecast). Evaluate with a train/test split and MAPE. That's it for v1. Everything else is iteration.
In this guide
- What "forecasting" actually means
- The tools you need
- A complete walkthrough — sales forecasting
- Choosing a model
- Evaluating a forecast properly
- Common beginner mistakes
- FAQ
<a id="what"></a>
What "forecasting" actually means
A time series is a sequence of values indexed by time — daily sales, hourly server load, monthly revenue, weekly support tickets. Forecasting is predicting future values from past ones.
Three things make it different from regular machine learning:
- Order matters. You can't shuffle the rows.
- There's autocorrelation. Today's value is related to yesterday's.
- There's seasonality. Patterns repeat at fixed intervals (daily, weekly, yearly).
The good news: pandas, scikit-learn, statsmodels, and a few specialist libraries handle the heavy lifting. You mostly have to learn which tool to reach for and how to evaluate honestly.
<a id="tools"></a>
The tools you need
You'll install five libraries — and never need anything else for ~80% of business forecasting:
pip install pandas numpy matplotlib statsmodels prophet
Optional but recommended once you've shipped your first forecast:
pip install scikit-learn skforecast
A Jupyter notebook (VS Code, Cursor, Hex, Deepnote, Google Colab — all work) is the friendliest environment.
<a id="walkthrough"></a>
A complete walkthrough — daily sales forecasting
Imagine a CSV sales.csv with two columns: date and sales. Daily values, two years of history. The goal: predict the next 30 days.
1. Load and look at it
import pandas as pd
import matplotlib.pyplot as plt
df = pd.read_csv("sales.csv", parse_dates=["date"])
df = df.set_index("date").sort_index()
df["sales"].plot(figsize=(10, 4), title="Daily sales")
plt.show()
Always plot first. You'll spot the obvious: an upward trend, a weekly pattern (weekends quieter), a holiday dip, a one-off promo spike. Whatever you see in the chart is what the model has to handle.
2. Split into train and test
For forecasting, you never randomly split. You hold out the most recent slice as the test set:
test_size = 30
train = df.iloc[:-test_size]
test = df.iloc[-test_size:]
This simulates "fit on what I know, predict what I don't."
3. A baseline — naïve forecast
Before any clever model, fit a baseline. The naïve forecast says: tomorrow looks like yesterday.
naive_pred = pd.Series([train["sales"].iloc[-1]] * test_size, index=test.index)
For a weekly-seasonal series, a better naïve is: this day next week looks like this day last week.
seasonal_naive = train["sales"].iloc[-7:].tolist() * (test_size // 7 + 1)
seasonal_naive = pd.Series(seasonal_naive[:test_size], index=test.index)
If your "clever" model can't beat this, the clever model is wrong.
4. Exponential smoothing — the workhorse
statsmodels ships with ETS (Error-Trend-Seasonal), one of the most reliable methods for typical business series.
from statsmodels.tsa.holtwinters import ExponentialSmoothing
model = ExponentialSmoothing(
train["sales"], seasonal_periods=7, trend="add", seasonal="add",
).fit()
ets_pred = model.forecast(test_size)
If you want to understand what's happening under the hood, our exponential smoothing tutorial goes deep.
5. Prophet — Facebook's "just works" model
Prophet shines on business data with holidays and missing values. It's verbose, forgiving, and fast.
from prophet import Prophet
prophet_df = train.reset_index().rename(columns={"date": "ds", "sales": "y"})
m = Prophet(weekly_seasonality=True, yearly_seasonality=True).fit(prophet_df)
future = m.make_future_dataframe(periods=test_size)
forecast = m.predict(future)
prophet_pred = forecast.set_index("ds")["yhat"].iloc[-test_size:]
6. Evaluate
Use Mean Absolute Percentage Error (MAPE) as your default — it's interpretable ("the forecast was off by 7%").
def mape(actual, predicted):
return ((actual - predicted).abs() / actual.abs()).mean() * 100
for name, pred in [("naive", naive_pred), ("seasonal_naive", seasonal_naive),
("ets", ets_pred), ("prophet", prophet_pred)]:
print(f"{name}: {mape(test['sales'], pred):.2f}% MAPE")
You'll get something like:
naive: 18.40%
seasonal_naive: 9.10%
ets: 6.80%
prophet: 7.10%
Now you know which to use. Often ETS wins for short horizons; Prophet wins when holidays are messy.
<a id="models"></a>
Choosing a model — a one-screen guide
| Situation | Reach for |
|---|---|
| Clean series, strong seasonality, short horizon | ETS / Holt-Winters |
| Holidays, missing data, business calendar | Prophet |
| Many related series (per store, per SKU) | skforecast or darts with LightGBM |
| Long history, complex autocorrelation | ARIMA / SARIMA — see our ARIMA in Python guide |
| You need explainability for stakeholders | ETS or linear regression with calendar features |
| You have hours of GPU time and care about the last 1% | Neural methods (N-BEATS, Temporal Fusion Transformer) — usually overkill |
For most business forecasting, you'll bounce between ETS and Prophet, occasionally adding tree-based models for cross-sectional data.
<a id="evaluating"></a>
Evaluating a forecast properly
Three rules:
- Always hold out the most recent slice as a test set. Random splits leak future into past.
- Use multiple metrics. MAPE is interpretable but breaks near zero; pair with RMSE.
- Use cross-validation for time series. Rolling-origin (a.k.a. walk-forward) splits the most recent N windows. statsmodels and
skforecastboth make this easy.
A model that's 6% MAPE on one test window and 30% on the next isn't reliable. You only find that out by repeating the evaluation.
<a id="mistakes"></a>
Common beginner mistakes
- Skipping the chart. Half of forecasting is noticing things by eye.
- No baseline. If you don't compare to naïve, you can't tell whether you actually helped.
- Data leakage. Using future information (a feature that's only known after the fact) inflates your training metric and crashes in production.
- Ignoring frequency. Daily data with missing days, irregular sampling, or duplicated timestamps will break every model. Fix the index first.
- Forecasting too far. A model that's great at 30 days is often useless at 365. Forecast to the horizon you actually need.
If you want to go deeper, our piece on the best forecasting methods for business is a complementary, method-by-method tour.
What to learn next
Once you can ship a v1 forecast, the next moves are:
- Add features — promotions, holidays, weather, marketing spend — and use
skforecastor LightGBM. - Try ARIMA / SARIMA when you want a more statistical model — start with our ARIMA in Python walkthrough.
- Read the diagnostics, not just the metric — residual plots, ACF/PACF — to catch structural problems.
The deepest hands-on path is the Hero Program; the free crash courses library includes a forecasting starter pack.
<a id="faq"></a>
FAQ
What's the easiest Python forecasting library for beginners? Prophet. It tolerates messy data, handles holidays, and runs out of the box. The trade-off: less control. Once you've shipped a Prophet model, learn ETS via statsmodels — it's the workhorse you'll fall back on for most business series.
Is forecasting in Python hard? The mechanics are easy — four lines for a v1 model. The hard parts are choosing the right horizon, building an honest evaluation, and explaining the result. Those are the skills worth investing in.
How much data do I need? For a seasonal model, you want at least two full cycles — so two full years of daily data for yearly seasonality, two months for weekly seasonality, two weeks for daily seasonality. Less than that, lean on naïve or simple regression with calendar features.
Can I forecast without Python? Yes — Excel handles linear trends and exponential smoothing, Power BI has built-in forecasting, and SAP/Oracle ship statistical engines. Python wins on flexibility, library breadth, and reproducibility. See no-code AI vs Python for business for the trade-off.
MAPE or RMSE? Use both. MAPE for stakeholder communication ("off by 7%"). RMSE for model selection when values are close to zero or there are outliers.
Next steps
Open a notebook. Pick a real series from your business — sales, demand, ticket volume — and walk through this guide end-to-end. The first version will be ugly; the second won't. From there, the Hero Program and our free crash courses cover the full forecasting toolbox.