Python pandas datareader isn't working [closed]
Asked Answered
H

1

8

Today, I was grabbing stock data using Python's pandas_datareader. Funny thing is it worked just several hours ago, but now I'm not able to grab stock data from yahoo-finance, but I can with google. I then upgraded pandas datareader in my command terminal, pip install pandas-datareader --upgrade. I then imported the upgraded package like usual, from pandas_datareader import data, wb.

And it still won't work, but it works for grabbing stock options. It should do acccording to this documentation for pandas datareader https://pypi.python.org/pypi/pandas-datareader/0.4.0

from pandas_datareader import Options

aapl = Options("AAPL" "yahoo")
aapl = aapl.get_all_data()

With google, grabbing stock data works.

import datetime
import pandas as pd
from pandas_datareader import data, wb

start = datetime.datetime(2016, 1, 1)
end = datetime.datetime(2017, 1, 1)

aapl = data.DataReader("AAPL", "google", start, end)

Yahoo-Finance doesn't work.

aapl = data.DataReader("AAPL", "yahoo", start, end)

This is so annoying! Can anyone help get stock data from Yahoo?

Here's the traceback:

aapl = data.DataReader("AAPL", "yahoo", start, end)
Traceback (most recent call last):

  File "", line 1, in 
    aapl = data.DataReader("AAPL", "yahoo", start, end)

  File "C:\Anaconda3\envs\p3\lib\site-packages\pandas_datareader\data.py", line 94, in DataReader
    session=session).read()

  File "C:\Anaconda3\envs\p3\lib\site-packages\pandas_datareader\yahoo\daily.py", line 77, in read
    df = super(YahooDailyReader, self).read()

  File "C:\Anaconda3\envs\p3\lib\site-packages\pandas_datareader\base.py", line 173, in read
    df = self._read_one_data(self.url, params=self._get_params(self.symbols))

  File "C:\Anaconda3\envs\p3\lib\site-packages\pandas_datareader\base.py", line 80, in _read_one_data
    out = self._read_url_as_StringIO(url, params=params)

  File "C:\Anaconda3\envs\p3\lib\site-packages\pandas_datareader\base.py", line 91, in _read_url_as_StringIO
    response = self._get_response(url, params=params)

  File "C:\Anaconda3\envs\p3\lib\site-packages\pandas_datareader\base.py", line 117, in _get_response
    raise RemoteDataError('Unable to read URL: {0}'.format(url))

RemoteDataError: Unable to read URL: http://ichart.finance.yahoo.com/table.csv
Harned answered 16/5, 2017 at 22:0 Comment(14)
what is the error message you get? it doesn't work is not very usefulWolk
Hi Maarteen, I get this error with yahoo, RemoteDataError: Unable to read URL: http://ichart.finance.yahoo.com/table.csv?s=AAPL&a=0&b=1&c=2017&d=4&e=16&f=2017&g=d&ignore=.csvHarned
The URL is simply not available. Try opening it in the Web browser.Nonchalant
I'm trying to grab data using Python, going to the website is not what I'm looking for. Also, I suggest people actually try out my code before replying to see if it works for them.Harned
... What do you think Python is doing? If you can't load the page (data) in a browser, how will Python load the data?Crutch
If the URL is not available, you cannot get it, no matter how you write or run your code.Nonchalant
It works for Google, and I'm still able to grab options using yahoo, but not stock data. So the newest pandas datareader doesn't work, I thought it would have considering it was released today. Guess I'm stuck using only Google.Harned
When I visit ichart.finance.yahoo.com right now it shows the message "Yahoo will be right back. Our engineers are working quickly to resolve the issue." So there's clearly a server-side issue right now. Just have a little patience and try again later.Frustule
In other words, the URL is not available, as stated a few comments back. So it has nothing to do with the new datareader, and checking the URL in a browser confirmed the issue. The service is down.Crutch
Thanks Xukrao, that's a relief. I wrote a huge algorithm that depends solely on pandas_datareader with yahoo. So it not working will just break the code in my algorithm.Harned
Eh, if anything, it gives you a chance you make your algorithm stronger :) How will your algorithm deal with this situation?Crutch
Thanks Rogan, hopefully this will be working again fairly soon. Probably use a conditional statement using an if yahoo works, use yahoo, else use google. I relied on "Adj Close" labelled columns for stock data using yahoo-finance, but google only gives "Close" labelled columns. Or maybe a try and exception statement might be better.Harned
Faced exactly same problem as you @HarnedPremillenarian
Yahoo has changed its historical data download page completely. Its still there, but the old URLs which pandas_datareader was using will not work. This has happened on the 15th or 16th depending on your time zone. One hopes someone is working on a fix!Toilette
P
5

As of the writing of this post, the website is down. Does not seem like an error on your end, as others have pointed out.

Reading the error message would give some indication to this, and a logical advancement from there would be to simply go to the URL in question: "http://ichart.finance.yahoo.com/table.csv" which pointed to being unavailable.

Pastor answered 16/5, 2017 at 22:49 Comment(4)
Has Yahoo said anything about when they will get it back working again?Sublett
Here is a link for discussion about the fix: github.com/pydata/pandas-datareader/issues/315Pastor
Hey Jeremy, i see that there is a 0.4.1 version. how come when I do pip install pandas-datareader -U it doesn't pick up the new version?Sublett
Hello @jason, when trying the command on my own computer, the version I installed was 0.4.0. After looking at the GitHub repo for pandas it says the latest version is 0.4.0 (github.com/pydata/pandas-datareader)Pastor

© 2022 - 2024 — McMap. All rights reserved.