title: Replace values in a dataframe column based on condition
body: <p>I have a seemingly easy task. Dataframe with 2 columns: A and B. If values in B are larger than values in A - replace those values with values of A. I used to do this by doing <code>df.B[df.B &gt; df.A] = df.A</code>, however recent upgrade of pandas started giving a <code>SettingWithCopyWarning</code> when encountering this chained assignment. Official documentation recommends using <code>.loc</code>.</p>
  
  <p>Okay, I said, and did it through <code>df.loc[df.B &gt; df.A, 'B'] = df.A</code> and it all works fine, unless column B has all values of <code>NaN</code>. Then something weird happens:</p>
  
  <pre><code>In [1]: df = pd.DataFrame({'A': [1, 2, 3],'B': [np.NaN, np.NaN, np.NaN]})
  
  In [2]: df
  Out[2]: 
     A   B
  0  1 NaN
  1  2 NaN
  2  3 NaN
  
  In [3]: df.loc[df.B &gt; df.A, 'B'] = df.A
  
  In [4]: df
  Out[4]: 
     A                    B
  0  1 -9223372036854775808
  1  2 -9223372036854775808
  2  3 -9223372036854775808
  </code></pre>
  
  <p>Now, if even one of B's elements satisfies the condition (larger than A), then it all works fine:</p>
  
  <pre><code>In [1]: df = pd.DataFrame({'A': [1, 2, 3],'B': [np.NaN, 4, np.NaN]})
  
  In [2]: df
  Out[2]: 
     A   B
  0  1 NaN
  1  2   4
  2  3 NaN
  
  In [3]: df.loc[df.B &gt; df.A, 'B'] = df.A
  
  In [4]: df
  Out[4]: 
     A   B
  0  1 NaN
  1  2   2
  2  3 NaN
  </code></pre>
  
  <p>But if none of Bs elements satisfy, then all <code>NaN</code>s get replaces with <code>-9223372036854775808</code>:</p>
  
  <pre><code>In [1]: df = pd.DataFrame({'A':[1,2,3],'B':[np.NaN,1,np.NaN]})
  
  In [2]: df
  Out[2]: 
     A   B
  0  1 NaN
  1  2   1
  2  3 NaN
  
  In [3]: df.loc[df.B &gt; df.A, 'B'] = df.A
  
  In [4]: df
  Out[4]: 
     A                    B
  0  1 -9223372036854775808
  1  2                    1
  2  3 -9223372036854775808
  </code></pre>
  
  <p>Is this a bug or a feature? How should I have done this replacement?</p>
  
  <p>Thank you!</p>