Hello. every one. I changed the code to the following:
import math
from pandas_datareader import data
#from pandas_datareader import *
import pandas_datareader.data as pdr
import numpy as np
import pandas as pd
from sklearn.preprocessing import MinMaxScaler
from keras.models import Sequential
from keras.layers import Dense, LSTM
import matplotlib.pyplot as plt
plt.style.use('fivethirtyeight')
import datetime
start = datetime.datetime(2020,1,1)
end = datetime.datetime(2020,4,17)
#pfizer = pdr.DataReader("PFE","yahoo",start,end)
#pfizer.head()
aapl = data.DataReader("AAPL",data_source='yahoo',start='2015-1-1', end='2015-12-31')['Adj Close']
Now I get the following error:
------------------------------------------------------------
TypeError Traceback (most recent call last)
Cell In[51], line 19
16 end = datetime.datetime(2020,4,17)
17 #pfizer = pdr.DataReader("PFE","yahoo",start,end)
18 #pfizer.head()
---> 19 aapl = data.DataReader("AAPL",data_source='yahoo',start='2015-1-1', end='2015-12-31')['Adj Close']
File ~\AppData\Local\Programs\Python\Python310\lib\site-packages\pandas\util\_decorators.py:210, in deprecate_kwarg.<locals>._deprecate_kwarg.<locals>.wrapper(*args, **kwargs)
208 raise TypeError(msg)
209 kwargs[new_arg_name] = new_arg_value
--> 210 return func(*args, **kwargs)
File ~\AppData\Local\Programs\Python\Python310\lib\site-packages\pandas_datareader\data.py:379, 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 ~\AppData\Local\Programs\Python\Python310\lib\site-packages\pandas_datareader\base.py:253, in _DailyBaseReader.read(self)
251 # If a single symbol, (e.g., 'GOOG')
252 if isinstance(self.symbols, (string_types, int)):
--> 253 df = self._read_one_data(self.url, params=self._get_params(self.symbols))
254 # Or multiple symbols, (e.g., ['GOOG', 'AAPL', 'MSFT'])
255 elif isinstance(self.symbols, DataFrame):
File ~\AppData\Local\Programs\Python\Python310\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