title: Why does this code throw a SettingWithCopyWarning?
body: <p>so I'm trying to create a new column that indicates whether or not the specified condition is True. I want the column to simply state "1" or "0". </p>
  
  <p>Here's my code:</p>
  
  <pre><code>data_sub = data_orig.loc[~pd.isnull(data_orig['Last_Audit_Date']), :]
  data_sub.reset_index(inplace=True)
  data_sub['PackageLengthFlag'] = (abs(data_sub.loc['AUDIT_Primary_Length'] - data_sub.loc[:, 'PKG_SUB_Length']) &gt; threshold)
  </code></pre>
  
  <p>I am thinking that True = 1 and False = 0 by default, if I convert it into integers, right? (thought I read somewhere saying this...)</p>
  
  <p>And here's the warning that I keep getting:</p>
  
  <pre><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></pre>
  
  <p>I read into:</p>
  
  <p><a href="https://stackoverflow.com/questions/20625582/how-to-deal-with-settingwithcopywarning-in-pandas">How to deal with SettingWithCopyWarning in Pandas?</a></p>
  
  <p><a href="https://stackoverflow.com/questions/37841525/correct-way-to-set-value-on-a-slice-in-pandas">Correct way to set value on a slice in pandas</a></p>
  
  <p><a href="https://stackoverflow.com/questions/26724378/pandas-settingwithcopywarning">Pandas SettingWithCopyWarning</a></p>
  
  <p>But I don't think they do what I am looking for. 
  Anyone has any advice? I know this question may sound painfully stupid, but still appreciate any help!</p>
  
  <p><strong>Edit</strong>
  I've added the 2 lines of code where I created the data_sub. Hope that helps!</p>