Created
May 5, 2022 15:35
-
-
Save dyegoaurelio/18a0114394ebfcc21bd70071583797a7 to your computer and use it in GitHub Desktop.
group solaredge data by month
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # %% | |
| import pandas as pd | |
| import datetime | |
| import locale | |
| # Change timelocale to current account's language setting in Odoo. | |
| locale.setlocale(locale.LC_TIME, 'pt_BR.UTF-8') | |
| df = pd.read_csv('solar-edge.csv', index_col=None) | |
| timestamps = pd.to_datetime(pd.Series(df.index, index=df.index)) | |
| df['months'] = timestamps.apply(lambda dd: dd.strftime('%B').capitalize()) | |
| df['months_index'] = timestamps.apply(lambda dd: int(dd.strftime('%-m'))) | |
| df.groupby('months') \ | |
| .sum().sort_values('months_index')\ | |
| .to_csv('out.csv') |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment