按日期对列进行排序

时间:2020-04-01 09:27:23

标签: python matplotlib

我的python代码:

df=pd.read_csv("path")
by_day=df.groupby('visit_date').first_name.count() 
# visit_date and first_name are columns in my data

plt.figure(figsize=(16,4))
ax=plt.subplot()
plt.plot(by_day.values,marker='o',markersize=8,linewidth=3)
plt.ylabel("Number of visits")
ax.set_xticks(range(len(by_day))[::8])
ax.set_xticklabels(by_day.index[::8],rotation=45)
plt.show()

如何按升序对date列进行排序,以将其显示在图的x轴上?

0 个答案:

没有答案