创建数据帧字典

Mil*_*use 7 python pandas

我创建了一个循环,使用字典输入生成数据帧.我想将结束数据帧插入一个新的字典,将其命名为组号(12345),然后开始循环,将新数据帧添加到同一个字典中,只有它具有新的组名称(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()
Run Code Online (Sandbox Code Playgroud)

显然我知道这是错的,我只是想知道我应该从哪里离开这里.

Sam*_*Sam 13

frames = {}

groups = ['123', '456']
for grp in groups:
    #do some calcs to get a dataframe called 'df'
    frames[grp] = df
Run Code Online (Sandbox Code Playgroud)