i have a dataframe that looks like this
name x y z ...
a test True 0
b set False 0
c set True 1
b fix True 1
c set False 0
i wanted to create multiple set of dfs with diff conditions
first df - for name = "..." that also satisfies the condition x = set
second df - for name = "..." that also satisfies the condition y = True
third df - for name = "..." that also satisfies the condition z = 1
ideally to have three df's for specific names
edit: i'm sorry, i should've mentioned it before. i know i could subset and copy paste the commands, but i wanted to repeat this for 6-7 names and wanted something more efficient.
CodePudding user response:
result = {}
for name in df.name.unique():
name_df = df[df.name == name]
result[name] = [
name_df[name_df.x == 'set'],
name_df[name_df.y],
name_df[name_df.z == 1]
]