I have a pandas dataframe as below with 3 columns. I want to compare each column to see if the value matches a particular string, and if yes, replace the value with NaN.
For example, if there are 5 values in column 1 of the data frame:
abcd
abcd
defg
abcd
defg
and if the comparison string is defg, the end result for column 1 in the data frame should be.
abcd
abcd
NaN
abcd
NaN