Say I have a dataframe:
| Do | Re | Mi | Fa | So |
|---|---|---|---|---|
| 1 | 0 | Foo | 100 | 50 |
| 1 | 1 | Bar | 75 | 20 |
| 0 | 0 | True | 59 | 59 |
| 1 | 1 | False | 0 | 12 |
How would I go about finding all rows where the value in columns "Do" and "Re" BOTH equal 1 AND "Fa" is higher than "So"?
I've tried a couple of ways, but they first returns an error complaining of ambiguity:
df['both_1']=((df['Do'] > df['Re']) & (df['Mi'] == df['Fa'] == 1))
I also tried breaking it down into steps, but I realised the last step will result in me bringing in both True and False statements. I only want True.
df['Do_1'] = df['Do'] == 1
df['Re_1'] = df['Re'] == 1
# This is where I realised I'm bringing in the False rows too
df['both_1'] = (df['Do1'] == df['Re_1'])```