I was wondering if you could help me with my problem. I have this main Data Frame :
df = pd.DataFrame({"Ind" : list(range(1,10)), "Price" : np.random.rand(9), "Year" : [2018,2018,2018,2018,2019,2019,2019,2019,2019]})
And I would to create 2 Data Frames based on the year The basic solution is to create 2 Data Frames separately :
df_2018 = df.loc[df.Year == 2018]
df_2019 = df.loc[df.Year == 2019]
My main goal is to try to assign the year directly to the name of the new Data Frame, I would like to do something like this :
i = "2018"
df_i = df.loc[df.Year == i]
Is there any solution ?
I really appreciate your help