Krishna Gupta
Krishna Gupta

Reputation: 166

How can i divide dataframe into multiple dataframes based on same values in columns

enter image description here

In the above image, I colored some rows with the same colors, so I want to create new data frames with the values of the same color. as you can see, the values of the same color are the same as an example - 0.8 multiple and CE option type values rows, in this entire data frame these same values come in 2 times, so I want to create these 3 rows new data frame, and like the same i want to do for all rows.

Upvotes: 0

Views: 68

Answers (1)

ldmichae
ldmichae

Reputation: 46

Below is some code that may help you.

df_dictionary = dict(tuple(your_dataframe.groupby('columns_to_groupby')))

This will produce a dictionary whose keys are the grouped values (in your case, "CE, PE, etc...") and whose values are the dataframes split by the grouping specified. Hope this helps.

Upvotes: 2

Related Questions