'how i can take rows with multi column
how i can choose rows with a condition on columns for example in below data frame i want use a list of columns to find same condition between them

lis_column1=['trigger3','height','trigger2']
df[df[lis_column1]>50]
and also when i add 'flag' column i get error becuase the items aren't number how i can apply condition on all my lis_column. (also consider 'flag') I mean:
lis_column1=
['trigger3','height','trigger2']
lis_column2=['flag']
df[df[lis_column1]>50] & df[df[lis_column2]==yellow]
Solution 1:[1]
I have not included student and flag because you can't compare string to int.
You can do something like this
df_subset = df[(df['height'] > 50) & (df['trigger2'] > 50) ].copy()
or when you have multiple conditions, I prefer this
cond1 = df['height'] > 50
cond2 = df['trigger2'] > 50
df_subset = df[(cond1) & (cond2)].copy()
Once you figure out the logic to compare student A to 50 or flag yellow to 50, you can add more conditions as mentioned above.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | Tejash Shah |
