问题描述
我正在尝试通过 Pandas 从 Yahoo Finance 中提取数据.我以前用过类似的拉,但在此之前没有遇到任何问题
I am trying to pull data from Yahoo Finance via Pandas. I have used similar pulls before, but haven't faced any issue before this
import pandas as pd
import numpy as np
import datetime as dt
from dateutil import parser
from pandas_datareader import data
from dateutil.relativedelta import relativedelta
end_date=dt.datetime.today()
begdate = end_date + relativedelta(years=-10)
data1 = data.get_data_yahoo('^DJI',begdate,end_date,interval='m')
这是我得到的错误
RemoteDataError: Unable to read URL: http://ichart.finance.yahoo.com/table.csv
我使用的是 Python 3.5
I am using Python 3.5
推荐答案
此问题已从 pandas-reader v0.5.0 开始修复.下面的修复不再适用.
This issue has been fixed as of v0.5.0 of pandas-reader. The fix below no longer applies.
正如其他人所指出的,API 端点已更改,并且已制作补丁 但尚未合并到 pandas-datareader
的 master
分支(截至 2017-05-21 6:19 UTC).修复程序位于此 branch 由 Rob Kimball (问题 | PR).对于临时修复(直到补丁合并到 master
),请尝试:
As pointed out by others, the API endpoint has changed and a patch has been made but hasn't been merged to the master
branch of pandas-datareader
yet (as of 2017-05-21 6:19 UTC). The fix is at this branch by Rob Kimball (Issue | PR). For a temporary fix (until the patch is merged into master
), try:
$ pip install git+https://github.com/rgkimball/pandas-datareader@fix-yahoo --upgrade
或者,如果您想调整源代码:
Or, in case you want to tweak the source code:
$ git clone https://github.com/rgkimball/pandas-datareader
$ cd pandas-datareader
$ git checkout fix-yahoo
$ pip install -e .
在 Python 上:
On Python:
import pandas_datareader as pdr
print(pdr.__version__) # Make sure it is '0.4.1'.
pdr.get_data_yahoo('^DJI')
这篇关于从雅虎财经中提取数据时出错的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!