-
-
Notifications
You must be signed in to change notification settings - Fork 18.1k
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
df.loc[:, 'col'] returning a view, but df.loc[df.index, 'col'] returning a copy #15631
Comments
this is as expected (see #6149), but see below.
yes if So i'll mark this as a compat issue if you'd do a pull-request would be great. This is actually a very small change, see https://github.com/pandas-dev/pandas/blob/master/pandas/core/indexing.py#L503 |
Thanks Jeff appreciate your insight on this. |
This looks fixed in master. Could use a test
|
As noted in the PRs for 1.1.4 that reverted the fix for this, we should actually investigate what the expected behaviour is, because it's not clear that the test that was added in #34996 is actually correct (cc @jbrockmendel) |
Code Sample, a copy-pastable example if possible
Problem description
[df.loc[:, 'col'] returning a view, but df.loc[df.index, 'col'] returning a copy, intended? how can I make sure it is returning a copy?]
Expected Output
I thought .loc[] was always returning a copy
pd.show_versions()
The text was updated successfully, but these errors were encountered: