title: python: pandas np.where vs. df.loc with multiple conditions
body: <p>Np.where has been giving me a lot of errors, so I am looking for a solution with df.loc instead.</p>
  
  <p>This is the np.where error I have been getting:</p>
  
  <pre><code>C:\Users\xxx\AppData\Local\Continuum\Anaconda2\lib\site-packages\ipykernel\__main__.py:1: 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
  
  See the caveats in the documentation: http://pandas.pydata.org/pandas-docs/stable/indexing.html#indexing-view-versus-copy
    if __name__ == '__main__':
  </code></pre>
  
  <p>I am working with the following dataframe df: </p>
  
  <pre><code>df = pd.DataFrame({'Column_A': ['AAA','AAA','ABC','CDE'],'checked': ['0','0','1','0'],'duplicate': ['True','True','False','False']})
  
      Column_A    checked   duplicate
  0   AAA             0      True
  1   AAA             0      True
  2   ABC             1      False
  3   CDE             0      False
  </code></pre>
  
  <p>I want to create an additional flag, if checked is 0 and duplicate is True.</p>
  
  <p>I tried this and it didn't work: </p>
  
  <pre><code>df['flag'] = (np.where((df['checked'] == 'Y') &amp;(df['duplicate'] == 'True'), 'Y', '0'))
  
  TypeError: invalid type comparison
  </code></pre>
  
  <p>I tried it with df.loc: </p>
  
  <pre><code>df['flag'] = (df.loc[df['checked'] == 'Y']&amp; df.loc[df['duplicate'] == 'True'], 'Y','0')
  
  TypeError: invalid type comparison
  </code></pre>
  
  <p>and I get the same error!</p>