I have a dataframe for person X (who has the role 'A'):

```
Friend  Role
Alice   A
Bob     A
Cooper  B
Don     C

```

I want to subset this dataframe and keep only those rows where the friends also have the role 'A'. Moreover, if the person X has the role B or C, I want to keep rows where the role is not 'A'.

So if person X has A the result will be:

```
Friend  Role
Alice   A
Bob     A

```

If person X has role 'B' or 'C' the result will be:

```
Friend  Role
Cooper  B
Don     C

```

How can I achieve this in Python?

EDIT: Based on the answers, I realize I should be more specific. I don't want to hardcode the rules. Essentially, we can have an object 'PersonXRole' which can be A, B or C. Based on this object, the resulting dataframe should be filtered according to the rules defined above.

I was initially thinking something like:

```
if PersonXRole=='A':
   return (people with role A)
else:
   return (people with role B or C)

```

But Im not sure this is an efficient way of doing it