Skip to content

Commit 9e2c3d6

Browse files
committed
Merge pull request #5477 from jreback/is_copy_bug
API: make sure _is_copy on NDFrame is always available (GH5475)
2 parents e684bdc + 1194775 commit 9e2c3d6

File tree

2 files changed

+11
-0
lines changed

2 files changed

+11
-0
lines changed

pandas/core/generic.py

+1
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,7 @@ class NDFrame(PandasObject):
7474
'_data', 'name', '_cacher', '_is_copy', '_subtyp', '_index', '_default_kind', '_default_fill_value']
7575
_internal_names_set = set(_internal_names)
7676
_metadata = []
77+
_is_copy = None
7778

7879
def __init__(self, data, axes=None, copy=False, dtype=None, fastpath=False):
7980

pandas/tests/test_indexing.py

+10
Original file line numberDiff line numberDiff line change
@@ -1736,6 +1736,16 @@ def f():
17361736
df = DataFrame({'A':['aaa','bbb','ccc'],'B':[1,2,3]})
17371737
df.loc[0]['A'] = 111
17381738

1739+
# make sure that _is_copy is picked up reconstruction
1740+
# GH5475
1741+
df = DataFrame({"A": [1,2]})
1742+
self.assert_(df._is_copy is False)
1743+
with tm.ensure_clean('__tmp__pickle') as path:
1744+
df.to_pickle(path)
1745+
df2 = pd.read_pickle(path)
1746+
df2["B"] = df2["A"]
1747+
df2["B"] = df2["A"]
1748+
17391749
def test_floating_index_doc_example(self):
17401750

17411751
index = Index([1.5, 2, 3, 4.5, 5])

0 commit comments

Comments
 (0)