-2

I want to iterate over the column "Name" which should have only "ROSE" and the next column should be "Fail" and should extract the column "places" corresponding to the FAIL and ROSE.

INPUT

Output :

OUTPUT

1 Answers1

0
df[(df["Name"] == "Rose") & (df["Condition"] == "Fail")]

Output

   Name   Status  Place
0  Rose     Fail  India
1  Rose     Fail    USA
2  Rose     Fail      X

To fetch only Place column as a list

df[(df["Name"] == "Rose") & (df["Condition"] == "Fail")]["Place"].tolist()

Output

   ['India', 'USA', 'X']
YuserT
  • 16
  • 2