Sub topic 11
Reading trends: smoothing, seasonality and year-over-year
This chapter assumes you already have a daily table of Search Console data with the columns date, query, page, clicks, impressions, ctr and position. It also assumes you know how to compute impression-weighted position. Here you will learn how to tell a real trend from weekday noise and seasonal swings.
Why daily numbers mislead
Daily clicks move for reasons unrelated to your work. Most sites get fewer visits on weekends. Holidays, news events and small ranking shifts add more noise. If you react to each day's change, you will chase noise.
A trend is a movement that continues over weeks. To see it, you must remove two kinds of repeating pattern:
- Weekly pattern: the same weekday shape repeats every seven days.
- Seasonality: a yearly shape, such as a travel site peaking before summer.
Smoothing with a rolling average
A rolling average replaces each day with the mean of the last N days. A 7-day window covers exactly one of each weekday, so the weekly pattern cancels out. A window of 5 or 10 days would leave a weekday bias.
The code below also shows a year-over-year comparison, which is explained in the next section.
import pandas as pd
df = pd.read_csv("gsc_daily.csv", parse_dates=["date"])
# Sum all rows per day. asfreq adds missing dates as 0 so windows stay correct.
daily = df.groupby("date")["clicks"].sum().asfreq("D", fill_value=0)
# 7-day rolling mean smooths the weekday pattern
trend = daily.rolling(7).mean()
# 28-day clicks compared with the same 28 days one year earlier
# (364 days keeps weekdays aligned)
yoy_change = daily.rolling(28).sum() / daily.shift(364).rolling(28).sum() - 1The asfreq call matters. If a date is missing and you skip this step, a "7-row" window can span eight or more calendar days. Be careful with fill_value=0. A gap caused by a failed collection job is not a day with zero clicks, so check for gaps before you fill them.
Year-over-year comparison
Comparing this month with last month mixes growth with seasonality. Comparing it with the same period a year earlier removes the seasonal shape, because both periods sit at the same point in the yearly cycle.
The code shifts by 364 days, not 365. 364 is 52 whole weeks, so Tuesday lines up with Tuesday. A 28-day window is also a whole number of weeks.
Common errors
| Error | Effect | Fix |
|---|---|---|
| Using a 5- or 10-day window | Weekday bias remains in the line | Use 7, 14 or 28 days |
| Averaging daily position values equally | Low-impression days distort the result | Weight by impressions |
| Comparing to 365 days ago | Weekdays misalign | Use 364 days |
| Filling collection gaps with zero | False drops appear | Mark gaps as missing |
| Reading year-over-year after a site migration | The baseline is not comparable | Annotate the change and compare segments |
Reading the result
Use both views together. Suppose the 7-day mean is rising but the year-over-year change is flat. Clicks are rising because the season is rising, and your performance has not improved. If year-over-year is positive while the season is falling, you are gaining ground.
Also check the size of the baseline. A +50% change on 40 clicks is far less reliable than +5% on 40,000. Apply these methods to groups of queries or pages, not single low-volume queries.
Exercise
Your 7-day rolling mean of clicks rose 20% in November, and last November was also up 22% over October. Is this evidence of improvement? Which comparison would you use to decide?
Show answer
Not by itself. The rise matches last year's seasonal pattern. Compare 28-day clicks with the same weekday-aligned 28 days a year earlier (shift by 364 days). If year-over-year change stays near zero, the rise is seasonal. If it is clearly positive, you have gained beyond the season.