Recall & Review
beginner
What is an expanding window function in data analysis?
An expanding window function calculates a statistic over all data points from the start up to the current point, growing the window as it moves forward.
Click to reveal answer
intermediate
Explain the difference between an expanding window and a rolling window.
An expanding window grows from the start to the current point, including all previous data, while a rolling window uses a fixed-size window that moves along the data.
Click to reveal answer
beginner
What does the ewm (exponentially weighted moving) function do?
The ewm function calculates statistics giving more weight to recent data points, making the result more sensitive to recent changes.
Click to reveal answer
intermediate
How does the 'span' parameter affect the ewm function?
The 'span' controls how quickly the weights decrease for older data; a smaller span means more weight on recent points, while a larger span smooths more over time.
Click to reveal answer
beginner
Show a simple Python example using pandas to calculate an expanding mean.
import pandas as pd
s = pd.Series([1, 2, 3, 4, 5])
expanding_mean = s.expanding().mean()
print(expanding_mean)
This prints the mean of all values from the start up to each point.Click to reveal answer
What does the expanding() function in pandas do?
✗ Incorrect
The expanding() function grows the window from the start to the current point, including all previous data.
Which window function gives more importance to recent data points?
✗ Incorrect
The ewm() function applies exponentially decreasing weights to older data, emphasizing recent points.
In ewm(span=5), what does the span control?
✗ Incorrect
Span controls the decay rate of weights in ewm; smaller span means faster decay.
Which pandas function would you use to calculate a rolling average over the last 3 data points?
✗ Incorrect
rolling(window=3) calculates statistics over a fixed window of 3 data points.
What will s.expanding().mean() return for s = pd.Series([2, 4, 6])?
✗ Incorrect
The expanding mean is calculated as [2, (2+4)/2=3, (2+4+6)/3=4].
Describe how expanding window functions work and give a real-life example where they might be useful.
Think about tracking a running average that includes all past data.
You got /3 concepts.
Explain the purpose of the ewm function and how changing its parameters affects the result.
Consider how recent events might be more important in stock prices.
You got /3 concepts.