Reputation: 595
I've created a loop that produces a dataframe using input from a dictionary. I'd like to insert the ending dataframe into a new dictionary, name it the group number (12345), then start the loop over adding the new dataframe into the same dictionary, only it would have the new groups name (54321):
frames = {}
groups = ['12345', '54321']
for x in groups:
# Runs a bunch of calculations with the ending output being a pandas df
frames = df.to_dict()
Obviously I know this is wrong, I'm just scratching my head as to where I should go from here.
Upvotes: 15
Views: 52185
Reputation: 4090
frames = {}
groups = ['123', '456']
for grp in groups:
#do some calcs to get a dataframe called 'df'
frames[grp] = df
Upvotes: 31