前提
python3、JupyterLab使用
実現したいこと
pandas_datareaderで株価の取得を行いたいのですが、先日までコードが動いていたのに
今日になってエラーが発生するようになりました。
解決方法をご教授いただきたく思います。
発生している問題・エラーメッセージ
TypeError Traceback (most recent call last) Input In [17], in <cell line: 4>() 1 start = pd.Timestamp('2017-11-16') 2 end = pd.Timestamp('2022-11-15') ----> 4 asa_data = web.DataReader(['9687.T'], 'yahoo', start, end)\ 5 [['High','Low','Open','Close','Volume','Adj Close']] 7 asa_data.info() File ~\anaconda3\lib\site-packages\pandas\util\_decorators.py:207, in deprecate_kwarg.<locals>._deprecate_kwarg.<locals>.wrapper(*args, **kwargs) 205 else: 206 kwargs[new_arg_name] = new_arg_value --> 207 return func(*args, **kwargs) File ~\anaconda3\lib\site-packages\pandas_datareader\data.py:370, in DataReader(name, data_source, start, end, retry_count, pause, session, api_key) 367 raise NotImplementedError(msg) 369 if data_source == "yahoo": --> 370 return YahooDailyReader( 371 symbols=name, 372 start=start, 373 end=end, 374 adjust_price=False, 375 chunksize=25, 376 retry_count=retry_count, 377 pause=pause, 378 session=session, 379 ).read() 381 elif data_source == "iex": 382 return IEXDailyReader( 383 symbols=name, 384 start=start, (...) 390 session=session, 391 ).read() File ~\anaconda3\lib\site-packages\pandas_datareader\base.py:258, in _DailyBaseReader.read(self) 256 df = self._dl_mult_symbols(self.symbols.index) 257 else: --> 258 df = self._dl_mult_symbols(self.symbols) 259 return df File ~\anaconda3\lib\site-packages\pandas_datareader\base.py:268, in _DailyBaseReader._dl_mult_symbols(self, symbols) 266 for sym in sym_group: 267 try: --> 268 stocks[sym] = self._read_one_data(self.url, self._get_params(sym)) 269 passed.append(sym) 270 except (IOError, KeyError): File ~\anaconda3\lib\site-packages\pandas_datareader\yahoo\daily.py:153, in YahooDailyReader._read_one_data(self, url, params) 151 try: 152 j = json.loads(re.search(ptrn, resp.text, re.DOTALL).group(1)) --> 153 data = j["context"]["dispatcher"]["stores"]["HistoricalPriceStore"] 154 except KeyError: 155 msg = "No data fetched for symbol {} using {}" TypeError: string indices must be integers
該当のソースコード
import
1import pandas_datareader as web 2import numpy as np 3import pandas as pd 4from sklearn.preprocessing import MinMaxScaler 5from keras.models import Sequential 6from keras.layers import Dense, LSTM 7import matplotlib.pyplot as plt 8plt.style.use('fivethirtyeight') 9 10df = web.DataReader('9687.T' , data_source='yahoo', start='2017-11-16', end='2021-11-15') 11df 12--------------------------------------------------------------------------- 13
あなたの回答
tips
プレビュー