title: Pandas logical indexing on a single column of a dataframe to assign values
body: <p>I am an R programmer and looking for a similar way to do something like this in R:</p>
  
  <pre><code>data[data$x &gt; value, y] &lt;- 1
  </code></pre>
  
  <p>(basically, take all rows where the x column is greater than some value and assign the y column at those rows the value of 1)</p>
  
  <p>In pandas it would seem the equivalent would go something like:</p>
  
  <pre><code>data['y'][data['x'] &gt; value] = 1
  </code></pre>
  
  <p>But this gives a SettingWithCopyWarning.</p>
  
  <p>Equivalent statements I've tried are:</p>
  
  <pre><code>condition = data['x']&gt;value
  data.loc(condition,'x')=1
  </code></pre>
  
  <p>But I'm seriously confused. Maybe I'm thinking too much in R terms and can't wrap my head around what's going on in Python.
  What would be equivalent code for this in Python, or workarounds?</p>