I am doing a business case on retrieving stock information. The teacher uses the code below to create DataFrames with stock information.
#The tech stocks we'll use for this analysis
tech_list = ['AAPL','GOOG','MSFT','AMZN']
#Set up End and Start times for data grab
end = datetime.now()
start = datetime(end.year - 1,end.month,end.day)
#For loop for grabing yahoo finance data and setting as a dataframe
for stock in tech_list:
# Set DataFrame as the Stock Ticker
globals()[stock] = DataReader(stock,'yahoo',start,end)
He uses globals()
to create the 4 dataframes with the techstock. I read in the question below that you can also use dictionary to achieve the same goal.
pandas set names of dataframes in loop
MY QUESTION is that i do not understand this line of code in the answer:
frames = {i:dat for i, dat in data.groupby('Sport')}
Can someone explain?