Hi all. Im kinda new to data science but i want to learn by doing. I found a tutorial video on YT to do stock analysis with jupyter notebook. But I get stock when trying to get data. I use anaconda. And i downloaded the pandas packet with the “pip install pandas-datareader” in the prompt.
Am i working in the wrong directory? I have multiple harddrives in my pc and can see it paths to both my G (where I installed anaconda) and C drive (for some reason unknown to me.)
I can also see it gives me a “type error” and that makes me think i might have to convert a index to a int or something.
Any help would be greatly appreciated.
import pandas_datareader.data as pdr
import datetime
import matplotlib.pyplot as plt
import sys
start_date = datetime.datetime(2020,1,1)
end_date = datetime.datetime(2020,12,31)
google = pdr.DataReader("GOOGL", data_source="yahoo", start=start_date, end=end_date)
---------------------------------------------------------------------------
TypeError Traceback (most recent call last)
~\AppData\Local\Temp\ipykernel_13168\1669214798.py in <module>
----> 1 google = pdr.DataReader("GOOGL", data_source="yahoo", start=start_date, end=end_date)
G:\anaconda3\lib\site-packages\pandas\util\_decorators.py in wrapper(*args, **kwargs)
205 else:
206 kwargs[new_arg_name] = new_arg_value
--> 207 return func(*args, **kwargs)
208
209 return cast(F, wrapper)
G:\anaconda3\lib\site-packages\pandas_datareader\data.py in DataReader(name, data_source, start, end, retry_count, pause, session, api_key)
368
369 if data_source == "yahoo":
--> 370 return YahooDailyReader(
371 symbols=name,
372 start=start,
G:\anaconda3\lib\site-packages\pandas_datareader\base.py in 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):
G:\anaconda3\lib\site-packages\pandas_datareader\yahoo\daily.py in _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
print(sys.path)
['C:\\Users\\MyDudé\\Documents\\Jupyter test 1', 'G:\\anaconda3\\python39.zip', 'G:\\anaconda3\\DLLs', 'G:\\anaconda3\\lib', 'G:\\anaconda3', '', 'G:\\anaconda3\\lib\\site-packages', 'G:\\anaconda3\\lib\\site-packages\\win32', 'G:\\anaconda3\\lib\\site-packages\\win32\\lib', 'G:\\anaconda3\\lib\\site-packages\\Pythonwin', 'G:\\anaconda3\\lib\\site-packages\\IPython\\extensions', 'C:\\Users\\MyDudé\\.ipython']