I have a dataframe as follows df:
Var_1 Var_2 Var_3 … Var_n date
0.016008 0.040933 0.121261 ... 146989.0 2018-03-21
0.015507 0.042487 0.116209 ... 144053.0 2018-03-22
0.015420 0.048447 0.125908 ... 154255.0 2018-03-23
0.014087 0.108278 0.115745 ... 167322.0 2018-03-24
0.016481 0.041167 0.078635 ... 210130.0 2018-03-25
I want to subset pairs of Var_i and date columns then return renamed dataframes with corresponding Var_i:
names_df = df.columns.to_list()
for i in names_df:
i = df.loc[:, ['date', i]] # or something like df_Var_i = ...
But, apparently such code does not work. I was wondering if there is a simple way to handle it.