Skip to content Skip to sidebar Skip to footer

Create Multiple DataFrames Based On Given Column Values

There's probably a simple solution to this that I just couldn't find... With the given DataFrame, how can I separate it into multiple DataFrames and go from something like: >>

Solution 1:

This is a simple groupby. Let me see if I find a dupe:

import pandas as pd

df = pd.DataFrame({
    'LOT': [102,104,162,102,104,102],
    'VAL': [22,424,65,4,34,6]
})

df = [x for _, x in df.groupby('LOT')]

Ok, I found something. However the answer seems overcomplicated so I'm gonna leave this here. Looks a lot like: Split pandas dataframe based on groupby


Post a Comment for "Create Multiple DataFrames Based On Given Column Values"