Home > database >  How to group by month and find count using python pandas
How to group by month and find count using python pandas

Time:02-02

I am trying to group the data by month (Created Date) and count the number of tuples for that month using python pandas. enter image description here

CodePudding user response:

You could use

grouped = df.groupby(df["Created Date"].dt.strftime("%Y-%m")).size()

.dt.strftime allows for formatting the date as text, in this case year-month (%Y is the four digit year, %m the month)

CodePudding user response:

Are you looking for:

df.resample('M', on='Created Date').count()
  •  Tags:  
  • Related