Python:绘制时间序列(日期和值)时出现问题 - 带有图像的奇怪图供参考

Python: Issue with plotting time series (date and values) - weird looking plots w image for reference

我在绘制时间序列数据时遇到了这个问题,其中索引日期会产生奇怪的图。我也试过 plot(x='Date', y='values') 但产生了奇怪的情节。

# splitting the column to account for date time.    
new = df["Gmt time"].str.split(" ", n = 1, expand = True)
df["Date"]= new[0]
df["Time"]= new[1]

df['Date'] = pd.to_datetime(df['Date'])

head of data values

df.plot(x='Date', y='Close')

Output of code above

df = df.set_index(df['Date'])

Output of code after setting the date as index.

如果您能让我知道我的代码哪里出了问题或需要解决以下问题,我将不胜感激。

通过在 read_csv() 中添加 dayfirst=True 解决了问题。 数据以 csv 文件的形式从杜高斯贝获取。