Python: SettingWithCopyWarning: A value is trying to be set on a copy of a slice from a DataFrame
<p>My pandas dataframe:</p>

<pre><code>dframe = pd.DataFrame({"A":list("abcde"), "B":list("aabbc"), "C":[1,2,3,4,5]},  index=[10,11,12,13,14])

    A   B   C
10  a   a   1
11  b   a   2
12  c   b   3
13  d   b   4
14  e   c   5
</code></pre>

<p>My desired output:</p>

<pre><code>    A   B   C   a   b   c
10  a   a   1   1   None    None
11  b   a   2   2   None    None
12  c   b   3   None    3   None
13  d   b   4   None    4   None
14  e   c   5   None    None    5
</code></pre>

<p>Idea is to create new column based on values in 'B' column, copy respective values in 'C' column and paste them in newly created columns. 
Here is my code:</p>

<pre><code>lis = sorted(list(dframe.B.unique()))

#creating empty columns
for items in lis:
   dframe[items] = None


 #here copy and pasting
    for items in range(0, len(dframe)):
        slot = dframe.B.iloc[items]
        dframe[slot][items] = dframe.C.iloc[items]
</code></pre>

<p>I ended up with this error:</p>

<pre><code>SettingWithCopyWarning: 
A value is trying to be set on a copy of a slice from a DataFrame

See the caveats in the documentation: http://pandas.pydata.org/pandas-docs/stable/indexing.html#indexing-view-versus-copy
  app.launch_new_instance()
</code></pre>

<p>This code worked well in Python 2.7 but not in 3.x. Where I'm going wrong?</p>