小编dlo*_*575的帖子

ValueError: view limit minimum -35738.3640567 小于 1 并且是无效的 Matplotlib 日期值

我是 matplotlib 的初学者。我正在尝试使用 matplotlib.pyplot 绘制数据框。问题是,每次我尝试绘制它时,都会出现以下错误:

ValueError: view limit minimum -35738.3640567 is less than 1 and is an invalid Matplotlib date value. This often happens if you pass a non-datetime value to an axis that has datetime units.

Run Code Online (Sandbox Code Playgroud)

根据错误,日期时间列中似乎有一个非日期时间值,但没有。

我试过使用 pd.to_datetime() 并尝试将时间戳的格式pd.to_datetime(df_google['datetime'], format = '%d/%m/%Y')更改为但没有任何变化。

这是我尝试使用的代码:

import matplotlib.pyplot as plt

df_google.plot()
plt.show()
Run Code Online (Sandbox Code Playgroud)

df_google 是一个带有列的数据框['datetime','price'],其中一些值如下:

     datetime        price
0  2018-05-15  1079.229980
1  2018-05-16  1081.770020
2  2018-05-17  1078.589966
3  2018-05-18  1066.359985
4  2018-05-21  1079.579956
5  2018-05-22  1069.729980
6  2018-05-23  1079.689941 …
Run Code Online (Sandbox Code Playgroud)

python matplotlib pandas

13
推荐指数
1
解决办法
3万
查看次数

标签 统计

matplotlib ×1

pandas ×1

python ×1