I have looked up this issue and most questions are for more complex replacements. However in my case I have a very simple dataframe as a test dummy.
The aim is to replace a string anywhere in the dataframe with an nan, however this does not seem to work (i.e. does not replace; no errors whatsoever). I've tried replacing with another string and it does not work either. E.g.
d = {'color' : pd.Series(['white', 'blue', 'orange']),
   'second_color': pd.Series(['white', 'black', 'blue']),
   'value' : pd.Series([1., 2., 3.])}
df = pd.DataFrame(d)
df.replace('white', np.nan)
The output is still:
      color second_color  value
  0   white        white      1
  1    blue        black      2
  2  orange         blue      3
This problem is often addressed using inplace=True, but there are caveats to that. Please also see Understanding inplace=True in pandas.
 
     
     
     
     
     
     
     
     
     
    