title: Why is pandas not allowing me to create a new column for this dataframe and throwing a setting with copy warning?
body: <p>I'm trying to create a column in a dataframe using the following code:</p>
  <pre><code>df['engagement_clicks_event_subscribers'] = df['brands_publishers_lifetime_clicks'] / df['brands_publishers_lifetime_events'] / df['content_subscriber_count']
  </code></pre>
  <p>For some reason, this simply does NOT run. It throws a SettingwithCopy warning, and no new column is created.</p>
  <p>The most confusing part to me is that it does run on a simpler mock dataframe that I just took from the pandas documentation, with no warnings:  <a href="https://pandas.pydata.org/docs/getting_started/intro_tutorials/05_add_columns.html" rel="nofollow noreferrer">https://pandas.pydata.org/docs/getting_started/intro_tutorials/05_add_columns.html</a></p>
  <p>The only thing I can think of here is that there is a dtype issue causing a copy to be created instead of a view.</p>
  <p>These columns are int64:</p>
  <pre><code>df['brands_publishers_lifetime_clicks']
  
  df['brands_publishers_lifetime_events'] 
  </code></pre>
  <p>This one is float64:</p>
  <pre><code> df['content_subscriber_count']
  </code></pre>
  <p>There are no NaN or null values.</p>
  <p>Any tips here would be appreciated, it's driving me fairly nuts.</p>
  <p>Edit to include the full traceback set of warning I get from running this line:</p>
  <pre><code>/Users/sangbinlee/PycharmProjects/pr-seismic/data_shaping.py:41: 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: https://pandas.pydata.org/pandas-docs/stable/user_guide/indexing.html#returning-a-view-versus-a-copy
    df['engagement_clicks_event_subscribers'] = df['brands_publishers_lifetime_clicks']/ df['brands_publishers_lifetime_events'] / df['content_subscriber_count']
  </code></pre>
  <p>I've also tried, per the documentation in the warning:</p>
  <pre><code>df.loc[:,'engagement_clicks_event_subscribers'] = df['brands_publishers_lifetime_clicks']/ df['brands_publishers_lifetime_events'] / df['content_subscriber_count']
  </code></pre>
  <p>This generated 3 times as many settingwithcopy warnings and also doesn't work.</p>