How to group and count rows by month and year using Pandas?

后端 未结 5 656
情歌与酒
情歌与酒 2020-12-13 20:33

I have a dataset with personal data such as name, height, weight and date of birth. I would build a graph with the number of people born in a particular month and year. I\'m

5条回答
  •  慢半拍i
    慢半拍i (楼主)
    2020-12-13 21:04

    As of April 2019: This will work. Pandas version - 0.24.x

    df.groupby([df.dates.dt.year.rename('year'), df.dates.dt.month.rename('month')]).size()

提交回复
热议问题