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

Conversation

arw2019
Copy link
Member

@arw2019 arw2019 commented Jun 25, 2020

@WillAyd
Copy link
Member

WillAyd commented Jun 25, 2020

I'm not sure about this - are we expecting that this loc call copies? @mroeschke @jreback

@@ -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):
Copy link
Contributor

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

Copy link
Member Author

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

def test_identity_slice_returns_new_object(self):

is very similar so moved it there

@arw2019 arw2019 requested a review from jreback June 26, 2020 17:38
@erfannariman
Copy link
Member

@arw2019 are you still working on this?

@arw2019
Copy link
Member Author

arw2019 commented Jun 30, 2020

@erfannariman yes I think this is ready to go, waiting for review

@jreback jreback added Indexing Related to indexing on series/frames, not to indexes themselves Testing pandas testing functions or related to the test suite labels Jun 30, 2020
@jreback
Copy link
Contributor

jreback commented Jun 30, 2020

@WillAyd

I'm not sure about this - are we expecting that this loc call copies? @mroeschke @jreback

yes this has been the case for a long time

@jreback jreback added this to the 1.1 milestone Jun 30, 2020
Copy link
Contributor

@jreback jreback left a 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.

@arw2019 arw2019 requested a review from jreback July 2, 2020 07:05
@jreback jreback merged commit 995ca49 into pandas-dev:master Jul 9, 2020
@jreback
Copy link
Contributor

jreback commented Jul 9, 2020

thanks @arw2019

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Indexing Related to indexing on series/frames, not to indexes themselves Testing pandas testing functions or related to the test suite
Projects
None yet
Development

Successfully merging this pull request may close these issues.

df.loc[:, 'col'] returning a view, but df.loc[df.index, 'col'] returning a copy
4 participants