Q:

How to name pandas dataframes in a loop by their key in python?

I would like to create data-frames in a loop, but name each data-frame using a key as not to overwrite each datafranme in the loop.
Here is a simplified version of my data-frame:
ID  Field  Value
1     A     1.1
2     A     1.2
3     A     2.4
4     B     1.7
5     B     4.3
6     C     2.2

So in this case I would like to end up with 3 data frames named A, B and C
 so this is what I tired:
df2= df.groupby(['Field'])
for key, group in df2:
   key = group.reset_index()

But ofcourse the name 'key' gets overwritten with each sucessive loop. 
How can I name each dataframe in the loop by its key?
I would lalso like to create a list of the created dataframes as to keep track of them.

A:

You want to store your objects in a dict:
df_dict = {}
for key, group in df2:
   df_dict[key] = group.reset_index()

