Jump into concepts and practice - no test required
or
Recommended
Test this pattern10 questions across easy, medium, and hard to know if this pattern is strong
Recall & Review
beginner
What is the trend component in a time series?
The trend is the long-term increase or decrease in the data over time. It shows the overall direction, like a steady rise or fall.
Click to reveal answer
beginner
Define seasonality in a time series.
Seasonality is a repeating pattern or cycle in the data that happens at regular intervals, like daily, weekly, or yearly.
Click to reveal answer
intermediate
How does seasonality differ from trend in time series data?
Trend shows the overall direction over a long time, while seasonality shows repeating patterns within shorter fixed periods.
Click to reveal answer
intermediate
Why is it important to separate trend and seasonality in time series analysis?
Separating them helps us understand the true underlying patterns and make better predictions by modeling each part correctly.
Click to reveal answer
beginner
Give a real-life example of seasonality in time series data.
Sales of ice cream often rise every summer and fall in winter, showing a yearly seasonal pattern.
Click to reveal answer
What does the trend component in a time series represent?
ASudden spikes in data
BRandom noise in data
CRepeating patterns at fixed intervals
DLong-term increase or decrease in data
✗ Incorrect
Trend shows the overall direction of data over a long period.
Which of the following is an example of seasonality?
AStock price steadily rising over years
BDaily temperature rising and falling every day
CWeekly sales increasing every weekend
DRandom fluctuations in sensor readings
✗ Incorrect
Weekly sales increasing every weekend is a repeating pattern at fixed intervals, which is seasonality.
Why do we separate trend and seasonality in time series analysis?
ATo better understand and predict data patterns
BTo remove all data points
CTo ignore seasonal effects
DTo increase noise in data
✗ Incorrect
Separating trend and seasonality helps us model and predict data more accurately.
Which component is NOT part of typical time series decomposition?
AClustering
BTrend
CNoise
DSeasonality
✗ Incorrect
Clustering is a machine learning technique, not a time series component.
If sales rise every December, this pattern is called:
ATrend
BSeasonality
CNoise
DOutlier
✗ Incorrect
A repeating yearly pattern like sales rising every December is seasonality.
Explain the difference between trend and seasonality in time series data.
Think about how data moves over years versus repeating cycles like months or weeks.
You got /4 concepts.
Why is identifying seasonality important when forecasting time series data?
Consider how ignoring regular cycles might confuse your forecast.
You got /4 concepts.
Practice
(1/5)
1. Which component of a time series shows the long-term upward or downward movement over time?
easy
A. Trend
B. Seasonality
C. Noise
D. Residual
Solution
Step 1: Understand the meaning of trend
The trend component represents the overall direction or pattern in the data over a long period, such as increasing sales over years.
Step 2: Differentiate from seasonality and noise
Seasonality repeats in fixed cycles (like monthly), and noise is random variation. Trend is the smooth long-term movement.
Final Answer:
Trend -> Option A
Quick Check:
Long-term direction = Trend [OK]
Hint: Trend = overall direction over time, not repeating cycles [OK]
Common Mistakes:
Confusing seasonality with trend
Thinking noise is trend
Mixing residual with trend
2. Which of the following is the correct Python code to plot seasonality in a time series using pandas?
easy
A. df['value'].plot()
B. df['value'].rolling(window=12).mean().plot()
C. df['value'].groupby(df.index.month).mean().plot()
D. df['value'].diff().plot()
Solution
Step 1: Identify how to extract seasonality
Seasonality repeats in fixed intervals like months, so grouping by month and averaging shows seasonal pattern.
Step 2: Check code options
df['value'].groupby(df.index.month).mean().plot() groups by month and plots mean, revealing seasonality. Others plot raw data, trend (rolling mean), or differences.
Final Answer:
df['value'].groupby(df.index.month).mean().plot() -> Option C
Quick Check:
Group by time period for seasonality plot [OK]
Hint: Group data by time unit (month) to see seasonality [OK]
Common Mistakes:
Plotting raw data only
Using rolling mean for seasonality
Plotting differences instead of seasonal groups
3. Given this Python code snippet, what will be the output type of seasonal?
import pandas as pd
import numpy as np
index = pd.date_range('2023-01-01', periods=12, freq='M')
data = np.sin(np.linspace(0, 2 * np.pi, 12))
df = pd.Series(data, index=index)
seasonal = df.groupby(df.index.month).transform('mean')
medium
A. A numpy array of length 12
B. A pandas Series with same length as df
C. A pandas DataFrame with 12 rows and 1 column
D. A single float value representing mean
Solution
Step 1: Understand groupby with transform
Using groupby with transform('mean') returns a Series aligned with original index, same length as df.
Step 2: Check output type
Since df is a Series, seasonal is also a Series with same length, each value replaced by group mean.
Final Answer:
A pandas Series with same length as df -> Option B
Quick Check:
groupby + transform returns Series matching original length [OK]
Hint: groupby + transform keeps original length Series [OK]
Common Mistakes:
Thinking transform returns single value
Confusing transform with aggregate
Expecting DataFrame instead of Series
4. You have this code to extract trend using rolling mean:
trend = df['value'].rolling(window=3).mean()
But the output has many NaN values at the start. How can you fix this?
medium
A. Use diff() instead of rolling mean
B. Change window to 1
C. Drop NaN values after rolling mean
D. Use min_periods=1 in rolling to reduce NaNs
Solution
Step 1: Understand rolling mean NaNs
Rolling mean with window=3 needs 3 values to compute, so first 2 are NaN by default.
Step 2: Use min_periods to allow fewer values
Setting min_periods=1 lets rolling mean compute with fewer points, reducing NaNs at start.
Final Answer:
Use min_periods=1 in rolling to reduce NaNs -> Option D
Quick Check:
min_periods controls minimum data points for rolling [OK]
Hint: Set min_periods=1 in rolling to avoid initial NaNs [OK]
Common Mistakes:
Changing window to 1 loses smoothing
Dropping NaNs loses early data
Using diff() does not fix NaNs
5. You have monthly sales data with a strong yearly seasonality and an upward trend. Which method best separates trend and seasonality components?
hard
A. Use moving average with window=12 for trend, then subtract to get seasonality
B. Use differencing with lag=1 to remove seasonality
C. Apply Fourier transform to remove trend
D. Use rolling mean with window=3 to capture seasonality
Solution
Step 1: Understand yearly seasonality and trend
Yearly seasonality repeats every 12 months; trend is slow upward movement.
Step 2: Choose method to separate components
Moving average with window=12 smooths out seasonality, capturing trend. Subtracting trend leaves seasonality.
Step 3: Evaluate other options
Differencing with lag=1 removes short-term changes, not yearly seasonality. Fourier transform is complex. Rolling mean with window=3 is too short for yearly seasonality.
Final Answer:
Use moving average with window=12 for trend, then subtract to get seasonality -> Option A
Quick Check:
Window matches season length to isolate trend [OK]
Hint: Match moving average window to season length to isolate trend [OK]