0

I hope the question is clear enough. I have one giant data set (30 mil+) and would like to split it up into 8 smaller ones.

Is there a way to name a data frame based on the i in the for loop?

So for example if I have a list with lst = ['machine_1', 'machine_2', 'machine_3'] and I would like to create dataframes for each of these, is it possible to get them so that the data frames are called df_machine_1, df_machine_2 and df_machine_3?

Something like:

lst = ['machine_1', 'machine_2', 'machine_3']

for i in lst:
    df_i = df[df['Machines'] == i]]

I know that this doesn't work, but is there another solution?

GT1992
  • 79
  • 6

1 Answers1

0

You could also consider making a dictionary with dict comprehension:

dfs = {i:df[df['Machines']==i] for i in lst}

And call them via their key, for example: dfs['machine_1']

Celius Stingher
  • 17,835
  • 6
  • 23
  • 53