I have a Dataframe df
:
name rank
A captain, general, soldier
B general, foo, major
C foo
D captain, major
E foo, foo, foo
I want to check if any cell in the column rank
consists of foo
and if it does replace the whole cell with foo
.
Expected output:
name rank
A captain, general, soldier
B foo
C foo
D captain, major
E foo
How can I do this?