pandas_exercises
pandas_exercises copied to clipboard
Alternative for 06_Stats/Wind_Stats/Step 12-14
From step12 to 14, it asked to downsample the record to a yearly/monthly/weekly frequency for each location.
The provided solution is like below:
data.groupby(data.index.to_period('A')).mean()
I think it would be simpler to use resample function as below:
data.resample('AS').mean()
data.resample('M').mean()
data.resample('W').mean()
I think it would be simpler to use resample function as below: data.resample('AS').mean() data.resample('M').mean() data.resample('W').mean()
@chenjj28 I agree. Plus, if you did need to return the index as a period still you can pass the kind='period' parameter.
data.resample('A', kind='period').mean()