I created this code below to extract each individual key as separate data frames. However, since the prim_keys contains colon in their name, e.g. '5091016:2'
, the resulting dataframes should be named something like data5091016:2
. But, it is impossible to access these datafarmes just typing that. How can I access these dataframes?
primkeys = list(data.prim_key.unique())
grouped = data.groupby(['prim_key'])
for i in primkeys:
globals()[f'data{i}'] = grouped.get_group(i)
Thanks already. Best.