Can't download tickers "Key errror date"

Question:

I’m just starting using python and when I try running this code that’s supposed to download the tickers a Key Error date appears.

import pandas as pd
import numpy as np
import datetime as dt
import math
from  pandas_datareader import data as wb
import matplotlib.pyplot as plt

stock_prices= pd.DataFrame()

tickers= ['tsla', 'appl', 'msft', 'goog', '^IXIC']
    
for i in tickers:
    stock_prices[i]= wb.DataReader(i, data_source='yahoo', start= s, end= e)['Adj Close']
Asked By: Carlos ZL

||

Answers:

Replace APPL by AAPL.

import pandas as pd
import numpy as np
import datetime as dt
import math
from  pandas_datareader import data as wb
import matplotlib.pyplot as plt

stock_prices= pd.DataFrame()

tickers= ['TSLA', 'AAPL', 'MSFT', 'GOOG', '^IXIC']

s = dt.datetime(2022,9,1)
e = dt.datetime(2022,9,9)
    
for i in tickers:
    stock_prices[i]= wb.DataReader(i, data_source='yahoo', start= s, end= e)['Adj Close']

stock_prices

>>> Output

enter image description here

Answered By: L'Artiste
Categories: questions Tags: ,
Answers are sorted by their score. The answer accepted by the question owner as the best is marked with
at the top-right corner.