Pandas DataReader TypeError

148 views Asked by At

So essentially I have been trying to use the DataReader function but to no avail.

I have imported all the relevant things in my code but everytime I use the DataReader function, I get a TypeError:

import pandas as pd
import pandas_datareader.data as web
import datetime as dt
import yfinance as yf

start_date = dt.datetime(2020, 1, 1)
end_date = dt.datetime(2021, 1, 1)

aapl_df = web.DataReader('AAPL', 'Yahoo', start=start_date, end=end_date)

For this I get this error:TypeError: download() got multiple values for argument 'start'

When I try this code instead:

import pandas_datareader.data as web
import pandas as pd

start_date = pd.to_datetime('2022-01-01')
end_date = pd.to_datetime('2022-06-14')

df = web.DataReader('AAPL', 'yahoo', start_date, end_date)
df.tail(10)

I get the output :

[100%%*] 1 of 1 completed

1 Failed download: ['AAPL']: ValueError("time data 'yahoo' does not match format '%Y-%m-%d'")

Can someone please help?

1

There are 1 answers

2
nisakova On

here, but the yahoo data returning null

from datetime import datetime as dt
import pandas as pd
import pytz
import yfinance as yf

tz = pytz.timezone("America/New_York") 
start_date = tz.localize(dt(2022,1,1))
end_date = tz.localize(dt(2022,6,14))
df = yf.download(['AAPL', 'yahoo'], start=start_date, end=end_date, auto_adjust=True)
df