Fixing panda's datareader from yahoo finance with Enthought Canopy

青春壹個敷衍的年華 提交于 2019-12-07 15:41:35

问题


pandas' datareader from yahoo finance is not working at the moment because yahoo changed the url pandas used to get the data from, yahoo changed it from 'http://ichart.yahoo.com/table.csv?... to 'http://ichart.finance.yahoo.com/table.csv?....

The error I'm getting is IOError: after 3 tries, Yahoo! did not return a 200 for url '...'

So, I tried editing data.py, according to this fix, but still no go. I'm using pandas 0.12, with Enthought Canopy. Do I need to compile something..? is there anything more required?


回答1:


in (assuming that the user is using Enthought Canopy for Windows, and it's stored in the default location):

C:\Users\...\AppData\Local\Enthought\Canopy\System\Lib\site-packages\pandas\io

change yahoo_URL = 'http://ichart.yahoo.com/table.csv?'

to yahoo_URL = 'http://ichart.finance.yahoo.com/table.csv?'

Save and restart Canopy




回答2:


Here is a current, working version of using Pandas datareader to fetch yahoo quotes:

from pandas.io.data import DataReader
from datetime import datetime

amd = DataReader('AMD',  'yahoo', datetime(2015,7,1), datetime(2015,7,1))
print(amd['Adj Close'][0])

Keep in mind that the returned dataset is an array. You need to enumerate said array to get the data, either by specifying your index, or with a for loop

The other keys you can use are Open, Close, High, Low, and Volume.

I have Pandas v 0.16.2

I hope this helps!



来源:https://stackoverflow.com/questions/20870956/fixing-pandas-datareader-from-yahoo-finance-with-enthought-canopy

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!