Bar plot with groupby

前端 未结 1 787
礼貌的吻别
礼貌的吻别 2021-02-05 07:20

My categorical variable case_satus takes on four unique values. I have data from 2014 to 2016. I would like to plot the distribution of case_status gro

相关标签:
1条回答
  • 2021-02-05 07:49

    I think you need add unstack for DataFrame:

    df.groupby('year').case_status.value_counts().unstack().plot.barh()
    

    Also is possible change level:

    df.groupby('year').case_status.value_counts().unstack(0).plot.barh()
    
    0 讨论(0)
提交回复
热议问题