【发布时间】:2021-07-07 07:25:40
【问题描述】:
我有一个数据框df 如下:
Student_id Date_of_exam(d/m/y) Student_Performance
1 1/4/2020 Excellent
1 30/12/2019 Poor
1 26/12/2019 Medium
2 3/1/2021 Medium
2 10/1/2021 Poor
3 4/5/2020 Poor
3 22/8/2020 Excellent
我如何获得以 x-axis 为月-年的条形图(例如:y-ticks:2019 年 12 月、2020 年 1 月、2020 年 2 月)和 y-axis - 学生总数(计数) Student_Performance == Poor.
请提供任何想法,在此先感谢。
【问题讨论】:
-
你能告诉我们你已经尝试过什么吗?
-
我是 python 新手,不知道如何继续,这是我提到的但没有正确
df['Date_of_exam'] = pd.to_datetime(df['Date_of_exam']) s = df.resample('M', on='Date_of_exam')[['Student_Performance'== 'Poor']].size()
标签: python python-3.x pandas dataframe matplotlib