问题解决:'numpy.int64' object has no attribute 'timestamp'

在学习Harrison的股票分析时,按照H神的代码运行时报错了。错误信息为:

'numpy.int64' object has no attribute 'timestamp'

这是由于股票数据是按时间作为index的,但是直接读取数据,是无法将data列作为index的,所以在pandas读取数据时,要设置下,代码如下所示:

df = pd.read_csv('google.csv',
                  index_col='Date',
                  parse_dates=True)

这样就可以了。

H神的博客地址为:
https://pythonprogramming.net/forecasting-predicting-machine-learning-tutorial/?completed=/training-testing-machine-learning-tutorial/

猜你喜欢

转载自blog.csdn.net/opp003/article/details/84776587
今日推荐