我正在尝试用Python创建一个plot
,日期作为我的x轴(12/6/2010格式)Picture is attached
我写的代码附在后面。我犯了一个错误。请帮忙
import pandas as pd
df1 = pd.read_csv(r"C:\Users\pc237\.spyder-py3\monthly_csv.csv")
df_1 = df1.loc[df1['Source'] == 'GCAG']
df_2 = df1.loc[df1['Source'] == 'GISTEMP']
import matplotlib.pyplot as plt
x1 = df_1['Date'],
y1 = df_1['Mean'],
x1 = [pd.to_datetime(d) for d in x1]
plt.scatter(x1,y1)
错误:
Traceback (most recent call last):
File "C:\Software\Eng_APPS\Anaconda3\lib\site-packages\pandas\tseries\converter.py", line 213, in convert
values = tools.to_datetime(values)
我认为这里不需要列表理解,因为x1已经是熊猫对象了。您需要将推断日期时间格式标志设置为True
相关问题 更多 >
编程相关推荐