When I try to retrieve stock prices from yahoo, or google (I've tried both) it keeps returning with this error. I don't know what it means or how to fix it. I have used this code before and it has worked well. Can you please help me with this error and a solution to fix it. Thanks.
import datetime as dt
import pandas as pd
import pandas_datareader.data as web
start = dt.datetime(2000,1,1)
end = dt.datetime(2004,1,1)
df= web.DataReader('TSLA', 'yahoo', start, end)
print(df.head)
ConnectionError: HTTPConnectionPool(host='ichart.finance.yahoo.com', port=80): Max retries exceeded with url: /table.csv?a=0&ignore=.csv&s=TSLA&b=1&e=1&d=0&g=d&f=2004&c=2000 (Caused by NewConnectionError(': Failed to establish a new connection: [Errno 8] nodename nor servname provided, or not known',))
Just change this part:
df=web.DataReader("TSLA","yahoo",start,end) to: df=web.DataReader("TSLA","google",start,end)
The problem here is with the yahoo search engine. So hopefully this solves the issue.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With