Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Alternative for 06_Stats/Wind_Stats/Step 12-14 #103

Open
chenjj28 opened this issue Jun 7, 2020 · 1 comment
Open

Alternative for 06_Stats/Wind_Stats/Step 12-14 #103

chenjj28 opened this issue Jun 7, 2020 · 1 comment

Comments

@chenjj28
Copy link

chenjj28 commented Jun 7, 2020

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

@mullinscr
Copy link

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants