Skip to content
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

TST: df.loc[:, 'col'] returning a view, but df.loc[df.index, 'col'] returning a copy #34996

Merged
merged 16 commits into from
Jul 9, 2020
Merged
10 changes: 10 additions & 0 deletions pandas/tests/indexing/test_loc.py
Original file line number Diff line number Diff line change
Expand Up @@ -894,6 +894,16 @@ def test_identity_slice_returns_new_object(self):
original_series[:3] = [7, 8, 9]
assert all(sliced_series[:3] == [7, 8, 9])

def test_loc_copy_vs_view(self):
# GH 15631
x = DataFrame(zip(range(3), range(3)), columns=["a", "b"])

y = x.copy()
q = x.loc[:, "a"]
q += 2

tm.assert_frame_equal(x, y)

def test_loc_uint64(self):
# GH20722
# Test whether loc accept uint64 max value as index.
Expand Down