I'm trying to get some data in yahoo and using pandas datareader, but I got this error:
['MSFT']: ValueError("time data 'yahoo' does not match format '%Y-%m-%d'")
I'm new to Python.
code
import pandas_datareader as data
import yfinance as yf
import datetime
yf.pdr_override()
start= datetime.datetime(2020, 1, 1)
end =datetime.datetime(2023, 1, 1)
df = data.DataReader('MSFT', 'yahoo', start, end)
print(df)
It seems you are trying to use
pandas_datareader as data, but I would recommend you usingyfinfancedirectly, by using the methoddownload. This function directly fetches the historical stock data for Microsoft (MSFT) from Yahoo Finance. It should work more reliably for your purpose.