生成错误:UnicodeDecodeError:' ascii'编解码器不能解码位置0的字节0xef:序数不在范围内(128)
数据示例:
2014-08-06 7:00,4.06E + 04,42878.05892
2014-08-06 8:00,4.40E + 04,42857.00667
我遵循了这个已接受的答案,但没有任何运气让它成功: timestamps passed to matplotlib.date2num: 'str' object has no attribute 'toordinal'
代码:
timeformat = '%Y-%m-%d %H:%M'
columns = ["Datetime","Prediction","Actual"]
dtypes = ["object","float","float"]
myResults1 = np.genfromtxt("/Users/project/results_1.csv", delimiter=",", names=columns, dtype=dtypes)
time = [datetime.strptime(i,timeformat) for i in myResults1['Datetime']]
predictions = myResults1['Prediction']
actual = myResults1['Actual']
fig = pyplot.figure()
ax1 = fig.add_subplot(3,2,1,axisbg='grey')
ax1.plot_date(time,predictions)
ax1.set_xlabel('Time')
ax1.set_ylabel('Prediction')
pyplot.setp(ax1.xaxis.get_majorticklabels(),rotation=25)
感谢任何有帮助的人!!