我有一个非常简单的数据框,如下所示。我试图操纵x轴(日期),所以它从1996年3月12日开始,到2016年3月12日结束,增量为365天。
Datafame:
Date A B
1996-31-12 10 3
1997-31-03 5 6
1997-31-07 7 5
1997-30-11 3 12
1997-31-12 4 10
1998-31-03 5 8
.
.
.
2016-31-12 3 9
#change date string to datetime variable
df12.Date = pd.to_datetime(df12.Date)
fig, ax = plt.subplots()
ax.plot_date(df12.Date,df12.A)
ax.plot_date(df12.Date,df12.B)
ax.xaxis.set_major_locator(mdates.YearLocator())
ax.xaxis.grid(True, which="major")
ax.yaxis.grid()
ax.xaxis.set_major_formatter(mdates.DateFormatter('%b\n%Y''))
plt.tight_layout()
plt.show()
当我尝试运行上面的代码时,我收到一条错误消息,我不确定它是什么意思--OverflowError:Python int太大而无法转换为C long。任何人都知道这意味着什么?如果没有,还有另一种方法可以做我想做的事吗?