Skip to content

missing _is_copy causes strangeness #5475

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
dsm054 opened this issue Nov 8, 2013 · 3 comments · Fixed by #5477
Closed

missing _is_copy causes strangeness #5475

dsm054 opened this issue Nov 8, 2013 · 3 comments · Fixed by #5477
Labels
Bug Indexing Related to indexing on series/frames, not to indexes themselves
Milestone

Comments

@dsm054
Copy link
Contributor

dsm054 commented Nov 8, 2013

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'
@jreback
Copy link
Contributor

jreback commented Nov 8, 2013

easy fix

unpicking doesn't hit the normal creation machinery

thanks for the report

@jtratner
Copy link
Contributor

jtratner commented Nov 8, 2013

Why not just define '_is_copy=None' on NDFrame?
On Nov 8, 2013 4:45 PM, "jreback" [email protected] wrote:

easy fix

unpicking doesn't hit the normal creation machinery

thanks for the report


Reply to this email directly or view it on GitHubhttps://github.com//issues/5475#issuecomment-28100586
.

@jtratner
Copy link
Contributor

jtratner commented Nov 8, 2013

That way, worst that happens is that we accidentally don't name something a
copy

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug Indexing Related to indexing on series/frames, not to indexes themselves
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants