title: replacing values on pandas without changing the nan values as well
body: <p>I have an issue trying to replace values using np.where without changing the nan values as well.</p>
  <p>here is the code I used but it changes the nan values as well although I don't them changed for now.</p>
  <pre><code>df[&quot;col&quot;] = np.where(df[&quot;col&quot;]&gt;2, 1, 0)
  </code></pre>
  <p>I tried using a mask, but it didn't work as well.</p>
  <pre><code>df[&quot;col&quot;] = np.ma.array(df[&quot;col&quot;], mask=np.isnan(df[&quot;col&quot;]))
  df[&quot;col&quot;] = np.where(df[&quot;col&quot;]&gt;2, 1, 0)
  </code></pre>
  <p>is there a way to do that?</p>