gpt4 book ai didi

python - 使用数据读取器时出现 ImmediateDeprecationError

转载 作者:行者123 更新时间:2023-11-28 21:36:17 25 4
gpt4 key购买 nike

import datetime as dt
import matplotlib.pyplot as plt
from matplotlib import style
import pandas as pd
import pandas_datareader.data as web
style.use('ggplot')
start = dt.datetime(2000,1,1)
end = dt.datetime(2016,12,31)

df = web.DataReader('INPX', 'yahoo', start, end)


ImmediateDeprecationError Traceback (most recent call last)
<ipython-input-11-d0b9e16fb581> in <module>()
----> 1 df = web.DataReader('INPX', 'yahoo', start, end)

/anaconda3/lib/python3.6/site-packages/pandas_datareader/data.py in DataReader(name, data_source, start, end, retry_count, pause, session, access_key)
289 """
290 if data_source == "yahoo":
--> 291 raise ImmediateDeprecationError(DEP_ERROR_MSG.format('Yahoo Daily'))
292 return YahooDailyReader(symbols=name, start=start, end=end,
293 adjust_price=False, chunksize=25,

ImmediateDeprecationError:
Yahoo Daily has been immediately deprecated due to large breaks in the API without the
introduction of a stable replacement. Pull Requests to re-enable these data
connectors are welcome.

See https://github.com/pydata/pandas-datareader/issues

我尝试了该链接,但找不到立即出现折旧错误的原因。我还尝试将 'yahoo' 更改为 'google' ie:df = web.DataReader('INPX', 'google', start, end) 但仍然出现错误:

/anaconda3/lib/python3.6/site-packages/pandas_datareader/google/daily.py:40: UnstableAPIWarning: 
The Google Finance API has not been stable since late 2017. Requests seem
to fail at random. Failure is especially common when bulk downloading.

warnings.warn(UNSTABLE_WARNING,UnstableAPIWarning)

RemoteDataError                           Traceback (most recent call last)
<ipython-input-12-5d16a3e9b68a> in <module>()
----> 1 df = web.DataReader('INPX', 'google', start, end)

/anaconda3/lib/python3.6/site-packages/pandas_datareader/data.py in DataReader(name, data_source, start, end, retry_count, pause, session, access_key)
313 chunksize=25,
314 retry_count=retry_count, pause=pause,
--> 315 session=session).read()
316
317 elif data_source == "iex":

/anaconda3/lib/python3.6/site-packages/pandas_datareader/base.py in read(self)
204 if isinstance(self.symbols, (compat.string_types, int)):
205 df = self._read_one_data(self.url,
--> 206 params=self._get_params(self.symbols))
207 # Or multiple symbols, (e.g., ['GOOG', 'AAPL', 'MSFT'])
208 elif isinstance(self.symbols, DataFrame):

/anaconda3/lib/python3.6/site-packages/pandas_datareader/base.py in _read_one_data(self, url, params)
82 """ read one data from specified URL """
83 if self._format == 'string':
---> 84 out = self._read_url_as_StringIO(url, params=params)
85 elif self._format == 'json':
86 out = self._get_response(url, params=params).json()

/anaconda3/lib/python3.6/site-packages/pandas_datareader/base.py in _read_url_as_StringIO(self, url, params)
93 Open url (and retry)
94 """
---> 95 response = self._get_response(url, params=params)
96 text = self._sanitize_response(response)
97 out = StringIO()

/anaconda3/lib/python3.6/site-packages/pandas_datareader/base.py in _get_response(self, url, params, headers)
153 msg += '\nResponse Text:\n{0}'.format(last_response_text)
154
--> 155 raise RemoteDataError(msg)
156
157 def _get_crumb(self, *args):

RemoteDataError: Unable to read URL: https://finance.google.com/finance/historical?q=INPX&startdate=Jan+01%2C+2000&enddate=Dec+31%2C+2016&output=csv
Response Text:

b'抱歉... body { font-family: verdana, arial, sans-serif;背景颜色:#fff;颜色:#000; }Google抱歉...

我们很抱歉...

...但您的计算机或网络可能正在发送自动查询。为了保护我们的用户,我们现在无法处理您的请求。

请参阅 Google Help了解更多信息。

Google Home '.

非常感谢您的帮助!

最佳答案

讨论的一个小变化here为我工作。只需使用

import pandas_datareader.data as web
sp500 = web.get_data_yahoo('SPY', start=start, end=end)

关于python - 使用数据读取器时出现 ImmediateDeprecationError,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/51244178/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com