Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR PYTHON

group by pandas

#calculate sum of sales grouped by month
df.groupby(df.date.dt.month)['sales'].sum()

date
1    34
2    44
3    31
Name: sales, dtype: int64
Source by www.statology.org #
 
PREVIOUS NEXT
Tagged: #group #pandas
ADD COMMENT
Topic
Name
2+5 =