Skip to content

Instantly share code, notes, and snippets.

@dyegoaurelio
Created May 5, 2022 15:35
Show Gist options
  • Select an option

  • Save dyegoaurelio/18a0114394ebfcc21bd70071583797a7 to your computer and use it in GitHub Desktop.

Select an option

Save dyegoaurelio/18a0114394ebfcc21bd70071583797a7 to your computer and use it in GitHub Desktop.
group solaredge data by month
# %%
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