title: Efficient way to update column value for subset of rows on Pandas DataFrame?
body: <p>When using Pandas to update the value of a column for specif subset of rows, what is the best way to do it?</p>
  
  <p>Easy example:</p>
  
  <pre><code>import pandas as pd
  
  df = pd.DataFrame({'name' : pd.Series(['Alex', 'John', 'Christopher', 'Dwayne']),
                     'value' : pd.Series([1., 2., 3., 4.])})
  </code></pre>
  
  <p>Objective: update the <code>value</code> column based on names length and the initial value of the value column itself.</p>
  
  <p>The following line achieves the objective:</p>
  
  <pre><code>df.value[df.name.str.len() == 4 ] = df.value[df.name.str.len() == 4] * 1000
  </code></pre>
  
  <p>However, this line filters the whole data frame two times, both in LHS and RHS. I assume is not the most efficient way. And it does not do it 'in place'. </p>
  
  <p>Basically I'm looking for the pandas equivalent to R data.table ':=' operator:</p>
  
  <pre><code>df[nchar(name) == 4, value := value*1000]
  </code></pre>
  
  <p>And for other kind of operations such:</p>
  
  <pre><code>df[nchar(name) == 4, value := paste0("short_", as.character(value))]
  </code></pre>
  
  <p>Environment: <code>Python 3.6</code> <code>Pandas 0.22</code></p>
  
  <p>Thanks in advance.</p>