title: Get a column value to be replaced with another column value based on condition
body: <p>Getting errors when replacing a column value with another column's value based on condition.</p>
  
  <p>Here is the code...</p>
  
  <pre><code>import pandas as pd
  import numpy as np
  
  df = pd.DataFrame({ 'A' : 1.,
  'B' : pd.Timestamp('20130102'),
  'C' : pd.Series(1,index=list(range(4)),dtype='float32'),
  'D' : [1, 2, 1, 3],
  'E' : pd.Categorical(["test","train","test","train"]),
  'F' : 'foo' })
  </code></pre>
  
  <p>Want to replace value of column E with F, if value of column D == 1.</p>
  
  <p>Tried the following alternatives...</p>
  
  <p><strong>Alternative A:</strong></p>
  
  <pre><code>df[df.D == 1]['E'] = df[df.D == 1]['F']
  </code></pre>
  
  <p>This gives <code>SettingWithCopyWarning: 
  A value is trying to be set on a copy of a slice from a DataFrame.
  Try using .loc[row_indexer,col_indexer] = value instead</code></p>
  
  <p><strong>Alternative B:</strong></p>
  
  <pre><code>mask = df['D'] == 1
  df.loc[mask, 'E'] = df.loc[mask, 'F']
  </code></pre>
  
  <p>...gives <code>ValueError: Cannot setitem on a Categorical with a new category, set the categories first</code></p>
  
  <p><strong>Alternative C:</strong></p>
  
  <pre><code>df.loc[mask, 'E'].replace(df.loc[mask, 'F'])
  df
  </code></pre>
  
  <p>...simply doesn't do anything.</p>
  
  <p>Where am I going wrong? What is the correct way to do this?</p>