pandas_exercises icon indicating copy to clipboard operation
pandas_exercises copied to clipboard

Alternative for 06_Stats/Wind_Stats/Step 12-14

Open chenjj28 opened this issue 5 years ago • 1 comments

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()

chenjj28 avatar Jun 07 '20 01:06 chenjj28

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()

mullinscr avatar Sep 20 '20 14:09 mullinscr