Python Pandas 数据读取器不工作

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/44012335/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-14 03:37:10  来源:igfitidea点击:

Python pandas datareader isn't working

pythonpandasanacondayahoo-finance

提问by MichaelRSF

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.

今天,我正在使用 Python 的 pandas_datareader 抓取股票数据。有趣的是它在几个小时前才起作用,但现在我无法从 yahoo-finance 获取股票数据,但我可以使用 google。然后我在我的命令终端中升级了 pandas datareader,pip install pandas-datareader --upgrade. 然后我像往常一样导入升级包,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

它仍然不起作用,但它适用于获取股票期权。它应该根据Pandas数据阅读器的文档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

采纳答案by Jeremy

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.

阅读错误消息会对此给出一些指示,从那里开始的合乎逻辑的进步是简单地转到有问题的 URL:“ http://ichart.finance.yahoo.com/table.csv”,它指出不可用.