When assigning to a column in a DataFrame, If I assign an existing column, the assignment works:

In [36]: df = pd.DataFrame({'a':[1,2,12], 'b':['a','b','a']})
In [37]: df.b = df.a
In [38]: print df
    a   b
0   1   1
1   2   2
2  12  12

[3 rows x 2 columns]

but assigning to a new column fails silently:

In [40]:df = pd.DataFrame({'a':[1,2,12], 'b':['a','b','a']})
In [41]:df.c = df.a
In [42]:print df
    a  b
0   1  a
1   2  b
2  12  a

[3 rows x 2 columns]

Comment From: jreback

see as #5904 (prob best to issue a warning if their is a name clash)

you are assigning not a column here, but just an attribute

e.g. people do this df.name = 'foo' this does not create a column nor should it

you can make a case for what you are suggesting to work , but the attribute access is really geting only (unless its a reassignment).

I personally think we should bank the reassignment actually.

Comment From: cancan101

I would be fine not allowing this at all. What confuses me is that I can use it for reassignment, but then if I forget and try to use for assignment, it just fails without telling me.

Comment From: jreback

yeh...I don't know when the reassignment was allowed...

try taking it out and see what breaks

I don't think its a big deal to break the API...but let's see

Comment From: TomAugspurger

Closing in favor of https://github.com/pandas-dev/pandas/issues/7175 (warn on setting)