基于时间序列算法的降雨预报

2024-04-19 05:48:25 发布

您现在位置:Python中文网/ 问答频道 /正文

dataset=pd.read_csv("rainfall in india 1901-2015.csv")
#parse strings to datetime type
dataset['YEAR']=pd.to_datetime(dataset['YEAR'],infer_datetime_format=True) 
indexedDataset = dataset.set_index(['YEAR'])

plt.xlabel("Date") 
plt.ylabel("Number of air passengers") 
plt.plot(indexedDataset)

TypeError Traceback (most recent call last) in () 1 plt.xlabel("Date") 2 plt.ylabel("Number of air passengers") ----> 3 plt.plot(indexedDataset)

TypeError: unhashable type: 'numpy.ndarray'


Tags: ofcsvtoinnumberdatetimedatetype
1条回答
网友
1楼 · 发布于 2024-04-19 05:48:25

matplotlib.pyplot不能像您给出的那样绘制原始数据帧。您需要为它指定一个X轴数组和一个Y轴数组,或者使用pandas plotting工具

# option 1
indexedDataset.plot(x="YEAR", y="passenger column name")

# option 2
plt.plot(indexedDataset["YEAR"].values, indexedDataset["passenger column name"].values)

相关问题 更多 >