2017-12-03 12 views
0

の読み込みエラーデータ:パンダのWebデータリーダーを使用して、Googleファイナンスからのデータを取得できません:パンダのWeb DataReaderを使用して、GoogleファイナンスからSPYためUnicodeDecodeError

import pandas_datareader.data as web dfSPY = web.DataReader('SPY', 'google', start_date, end_date)

File "/home/user/Projects/pmb/dataaccess.py", line 63, in import_data dfSPY = web.DataReader('SPY', 'google', start_date, end_date) File "/home/user/anaconda3/envs/quant35/lib/python3.5/site-packages/pandas_datareader-0.5.0-py3.5.egg/pandas_datareader/data.py", line 137, in DataReader session=session).read() File "/home/user/anaconda3/envs/quant35/lib/python3.5/site-packages/pandas_datareader-0.5.0-py3.5.egg/pandas_datareader/base.py", line 181, in read params=self._get_params(self.symbols)) File "/home/user/anaconda3/envs/quant35/lib/python3.5/site-packages/pandas_datareader-0.5.0-py3.5.egg/pandas_datareader/base.py", line 79, in _read_one_data out = self._read_url_as_StringIO(url, params=params) File "/home/user/anaconda3/envs/quant35/lib/python3.5/site-packages/pandas_datareader-0.5.0-py3.5.egg/pandas_datareader/base.py", line 98, in _read_url_as_StringIO out.write(bytes_to_str(text)) File "/home/user/anaconda3/envs/quant35/lib/python3.5/site-packages/pandas/compat/init.py", line 73, in bytes_to_str return b.decode(encoding or 'utf-8')

UnicodeDecodeError: 'utf-8' codec can't decode byte 0xe3 in position 34539: invalid continuation byte

答えて

1

これはあなたの中に未解決の問題ですここでそれを見ることができます:https://github.com/pydata/pandas-datareader/issues/424

これは、私はgithubのからのコメントに基づいて解決する方法である:

チェックI pandas_datareader/google/daily.pyのGoogleDailyReader.url()は 'http://www.google.com/finance/historical'を返します。 その場合は、「http://finance.google.com/finance/historical」に変更してください。 (www-> finance) 昨日PyCharmにpandas-datareaderをダウンロードしたとき、GoogleDailyReader.url()の戻り値は 'http://www.google.com/finance/historical'でした。どうしてか分かりません。

テストそれで:

`/ usr/local/libに(あなたの`のdist-packages`フォルダに `pandas_datareader /グーグル/ daily.py`を開くことを意味する "に変更し、" こと
import pandas_datareader as pdr 
c = pdr.google.daily.GoogleDailyReader() 

c.url 
# http://www.google.com/finance/historical' 

pdr.__version__ 
# '0.5.0' 
+1

注意/ python3.4/'など)をrootとして実行し、ソースコードを変更します。 –

関連する問題