-
-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Clarify rules for copies vs views when indexing #512
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
Conversation
@jhamman any thoughts? |
|
||
Like pandas, whether array indexing returns a view or a copy of the underlying | ||
data depends entirely on numpy: | ||
The label based selection methods :py:meth:`~xray.Dataset.sel`, |
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.
also sel_points
* Label-based indexing with arrays returns a copy. | ||
* Label-based indexing with scalars returns a view or a copy, depending | ||
upon if the corresponding positional indexer can be represented as an | ||
integer or a slice object. |
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.
for the last point, an example showing both behaviors may be helpful.
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.
unfortunately, the distinction here is pretty complex and I'm not even sure I understand it fully...
I made a few comments. I think you'll have to sort out the merge conflicts coming from #507. |
bb51a8e
to
5814a12
Compare
Revised and rebased. |
I'm not able to build the docs from where I am but from what I can tell, this looks good. |
Clarify rules for copies vs views when indexing
This mostly reorganizes/updates the indexing documentation.
It also catches an edge case where a slice based indexer could be converted silently into array indexer. This is a strange edge case involving unsorted or duplicate indexes that arguably pandas shouldn't allow anyways.