title: Copy all values in a column to a new column in a pandas dataframe
body: <p>This is a very basic question, I just can not seem to find an answer.</p>
  <p>I have a dataframe like this, called <code>df</code>:</p>
  <pre><code>  A     B     C
   a.1   b.1   c.1
   a.2   b.2   c.2
   a.3   b.3   c.3
  </code></pre>
  <p>Then I extract all the rows from <code>df</code>, where column <code>B</code> has a value of 'b.2'.  I assign these results to <code>df_2</code>.</p>
  <pre><code>df_2 = df[df['B'] == 'b.2']
  </code></pre>
  <p><code>df_2</code> becomes:</p>
  <pre><code>  A     B     C
   a.2   b.2   c.2
  </code></pre>
  <p>Then, I copy all the values in column <code>B</code> to a new column named <code>D</code>. Causing <code>df_2</code> to become:</p>
  <pre><code>  A     B     C     D
   a.2   b.2   c.2   b.2
  </code></pre>
  <p>When I preform an assignment like this:</p>
  <pre><code>df_2['D'] = df_2['B']
  </code></pre>
  <p>I get the following warning:</p>
  <blockquote>
  <p>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</p>
  <p>See the the caveats in the documentation:
  <a href="http://pandas.pydata.org/pandas-docs/stable/indexing.html#indexing-view-versus-copy" rel="nofollow noreferrer">http://pandas.pydata.org/pandas-docs/stable/indexing.html#indexing-view-versus-copy</a></p>
  </blockquote>
  <hr />
  <p>I have also tried using <a href="https://pandas.pydata.org/pandas-docs/stable/reference/api/pandas.DataFrame.loc.html" rel="nofollow noreferrer"><code>loc</code></a> when creating <code>df_2</code> like this:</p>
  <pre><code>df_2 = df.loc[df['B'] == 'b.2']
  </code></pre>
  <p>However, I still get the warning.</p>
  <p>Any help is greatly appreciated.</p>