我有一个非常简单的数据框,如下所示。我试图操纵 x 轴(日期),使其从 1996 年 31 月 12 日开始,到 2016 年 31 月 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()
Run Code Online (Sandbox Code Playgroud)
当我尝试运行上面的代码时,我收到一条错误消息,我不确定它的含义 - OverflowError: Python int太大,无法转换为C long。有人知道这意味着什么吗?如果没有,还有其他方法可以做我想做的事吗?
归档时间: |
|
查看次数: |
1540 次 |
最近记录: |