In pandas I can search and replace all fields that contain the word fish, for example, using df.replace(r'.*fish.*', 'foo', regex = True)
.
But how do I search and replace all fields that don't contain the word fish?
That is in my example replace all fields that don't contain the word fish with the word 'foo'.
For example, say the dataframe is
applefish pear
water afishfarm
I would like this to be transformed to
applefish foo
foo afishfarm