SyntaxFix
Write A Post
Hire A Developer
Questions
Slightly alternative solution to @jpp's but outputting a YearMonth string:
YearMonth
df['YearMonth'] = pd.to_datetime(df['Date']).apply(lambda x: '{year}-{month}'.format(year=x.year, month=x.month)) res = df.groupby('YearMonth')['Values'].sum()