I have a Data-frame df which is as follows:
| date | Revenue |
|-----------|---------|
| 6/2/2017 | 100 |
| 5/23/2017 | 200 |
| 5/20/2017 | 300
Try this:
Chaged the date column into datetime formate.
---> df['Date'] = pd.to_datetime(df['Date'])
Insert new row in data frame which have month like->[May, 'June']
---> df['months'] = df['date'].apply(lambda x:x.strftime('%B'))
---> here x is date which take from date column in data frame.
Now aggregate aggregate data on month column and sum the revenue.
--->response_data_frame = df.groupby('months')['Revenue'].sum()
---->print(response_data_frame)
output -:
| month | Revenue |
|-------|---------|
| May | 500 |
| June | 1000 |