Closed
Description
Note the duplication of the assignment is not a copy/paste error-- the first one works, the second one fails, presumably because a different path is taken if the column already exists than if it doesn't.
>>> pd.__version__
'0.12.0-1081-ge684bdc'
>>> df = pd.DataFrame({"A": [1,2]})
>>> df._is_copy
False
>>> df.to_pickle("tmp.pk")
>>> df2 = pd.read_pickle("tmp.pk")
>>> hasattr(df2, "_is_copy")
False
>>> df2["B"] = df2["A"]
>>> df2["B"] = df2["A"]
Traceback (most recent call last):
File "<ipython-input-155-e1fb2db534a8>", line 1, in <module>
df2["B"] = df2["A"]
File "/usr/local/lib/python2.7/dist-packages/pandas-0.12.0_1081_ge684bdc-py2.7-linux-i686.egg/pandas/core/frame.py", line 1841, in __setitem__
self._set_item(key, value)
File "/usr/local/lib/python2.7/dist-packages/pandas-0.12.0_1081_ge684bdc-py2.7-linux-i686.egg/pandas/core/frame.py", line 1907, in _set_item
self._check_setitem_copy()
File "/usr/local/lib/python2.7/dist-packages/pandas-0.12.0_1081_ge684bdc-py2.7-linux-i686.egg/pandas/core/generic.py", line 1001, in _check_setitem_copy
if self._is_copy:
File "/usr/local/lib/python2.7/dist-packages/pandas-0.12.0_1081_ge684bdc-py2.7-linux-i686.egg/pandas/core/generic.py", line 1525, in __getattr__
(type(self).__name__, name))
AttributeError: 'DataFrame' object has no attribute '_is_copy'