Recall & Review
beginner
What is the purpose of resampling time series data in pandas?
Resampling changes the frequency of time series data, like converting daily data to monthly data, by aggregating or interpolating values.
Click to reveal answer
beginner
How does
groupby help when resampling time data?Using
groupby lets you split data into groups (like by category) and then resample each group separately, keeping the groups distinct.Click to reveal answer
beginner
What pandas method is used to resample time series data?
The
resample() method is used to change the frequency of time series data, such as 'D' for daily or 'M' for monthly.Click to reveal answer
beginner
Why do you need to set a datetime column as the index before resampling?
Resampling works on the datetime index, so setting the datetime column as the index tells pandas how to group data by time.
Click to reveal answer
intermediate
What does the following code do?<br>
df.groupby('category').resample('M').sum()It groups the data by 'category', then resamples each group to monthly frequency, summing values in each month for each category.
Click to reveal answer
Which pandas method changes the frequency of time series data?
✗ Incorrect
The resample() method changes the frequency of time series data.
Before resampling, what must you do with the datetime column?
✗ Incorrect
The datetime column must be set as the index for resampling to work.
What does
groupby('category').resample('W').mean() do?✗ Incorrect
It groups by category, resamples each group weekly, then calculates the mean.
If you want monthly sums per group, which code is correct?
✗ Incorrect
You must group first, then resample each group monthly and sum.
What frequency string means 'daily' in pandas resample?
✗ Incorrect
'D' stands for daily frequency in pandas resample.
Explain how to resample time series data separately for each group in a DataFrame.
Think about the order: group first, then resample.
You got /4 concepts.
Describe why resampling requires a datetime index and what happens if you don't set it.
Consider how pandas knows how to split data by time.
You got /3 concepts.