Plot number of occurrences from Pandas DataFrame

后端 未结 2 795
自闭症患者
自闭症患者 2021-01-02 04:53

I have a DataFrame with two columns. One of them is containing timestamps and another one - id of some action. Something like that:

2000-12-29 00:10:00     a         


        
2条回答
  •  清酒与你
    2021-01-02 05:27

    You can get the counts by using

    df.groupby([df.index.date, 'action']).count()
    

    or you can plot directly using this method

    df.groupby([df.index.date, 'action']).count().plot(kind='bar')
    

    You could also just store the results to count and then plot it separately. This is assuming that your index is already in datetimeindex format, otherwise follow the directions of @mkln above.

提交回复
热议问题