-
-
Notifications
You must be signed in to change notification settings - Fork 18.2k
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
Conversation
I'm not sure about this - are we expecting that this loc call copies? @mroeschke @jreback |
pandas/tests/indexing/test_loc.py
Outdated
@@ -346,6 +346,16 @@ def test_loc_index(self): | |||
result = df.loc[pd.array(mask, dtype="boolean")] | |||
tm.assert_frame_equal(result, expected) | |||
|
|||
def test_loc_copy_vs_view(self): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
hmm I am almost sure we have other tests about this, can you check and co-locate
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes you're right. This one
pandas/pandas/tests/indexing/test_loc.py
Line 872 in f5b2e5a
def test_identity_slice_returns_new_object(self): |
is very similar so moved it there
@arw2019 are you still working on this? |
@erfannariman yes I think this is ready to go, waiting for review |
yes this has been the case for a long time |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
hmm can you add both examples from the OP.
thanks @arw2019 |
black pandas
git diff upstream/master -u -- "*.py" | flake8 --diff