title: Replace non-zero values with 1
body: <p>I have a dataset that looks like this:</p>
  
  <pre><code>id    col1   col2   col3
  123   10     0      82
  456   0      90     16
  987   0      0      0
  </code></pre>
  
  <p>I'd like to replace all non-zero values in the columns that are not id with 1.  </p>
  
  <p>I've tried:</p>
  
  <pre><code>df.col1 = df.where(df.col1 != 0, 1)
  </code></pre>
  
  <p>But that replaces the non-zeroes with 1s and the zeros with the id.  </p>
  
  <p>Then I tried setting a new df to this function:</p>
  
  <pre><code>df2 = df.col1 = df.where(df.col1 != 0, 1)
  </code></pre>
  
  <p>And that works except it changes the id column to a 1 where it changed the non-zero value to a 1.  </p>
  
  <p>Any help troubleshooting the codes that are not working or another approach would be greatly appreciated!</p>