I'm trying to convert the following code's output into 2 lists, dates and prices, which contain the dates and prices that are outputted as a dtype:float64
from pandas_datareader import data
def get_stock_data(ticker, start, end):
stock_data = data.DataReader(ticker, start=start, end=end, data_source='yahoo')['Close']
return stock_data
print(get_stock_data('TSLA', '2021-01-01', '2021-01-31'))
stock_data.tolist() gives me the prices but how do I get the dates?
This could be any arbitrary set of start and end dates so I don't want to manually create a list for one test case.