使用数据读取器时的InstantDeprecationError

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',即:df = web.DataReader('INPX','google',开始,结束),但仍然存在错误:


/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)

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


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



料青山看我应如是
浏览 213回答 2
2回答

jeck猫

只需使用import pandas_datareader.data as websp500 = web.get_data_yahoo('SPY', start=start, end=end)

精慕HU

该错误是不言自明的。Yahoo API已更改,因此从Yahoo API读取的旧的Pandas代码不再起作用。你读过这个讨论有关API的变化及其对大熊猫的影响?本质上,Pandas无法读取新的Yahoo API,并且将花费很长时间来编写新代码,因此临时解决方案是在ImmediateDeprecationError每次有人尝试将Pandas用于Yahoo API时提出建议。
打开App,查看更多内容
随时随地看视频慕课网APP

相关分类

Python