时间序列绘制图形,就要考虑非工作日等日期剔除问题。
首先,要明确是跳过没有数据的区域,还是对缺失数据的日期进行补零。
跳过的办法:
plt.plot(list(range(df3.shape[0])),df3['total_amt'])
plt.xticks(list(range(df3.shape[0])),[str(index) for index in df3['date_col']],rotation=45,horizontalalignment='right')
plt.xlabel('时间线',fontsize=13)
plt.ylabel('总额',fontsize=13)
如图:
补零:
就新建一个基表,左连接去补零喽。
觉得不错请打赏~