html_url,issue_url,id,node_id,user,created_at,updated_at,author_association,body,reactions,performed_via_github_app,issue
https://github.com/pydata/xarray/pull/802#issuecomment-233596724,https://api.github.com/repos/pydata/xarray/issues/802,233596724,MDEyOklzc3VlQ29tbWVudDIzMzU5NjcyNA==,4160723,2016-07-19T10:48:56Z,2016-07-19T10:48:56Z,MEMBER,"Thanks again @shoyer for your reviews and comments!
Merging this PR broke the tests added in #881. I fixed that in #903.
","{""total_count"": 0, ""+1"": 0, ""-1"": 0, ""laugh"": 0, ""hooray"": 0, ""confused"": 0, ""heart"": 0, ""rocket"": 0, ""eyes"": 0}",,143264649
https://github.com/pydata/xarray/pull/802#issuecomment-225236223,https://api.github.com/repos/pydata/xarray/issues/802,225236223,MDEyOklzc3VlQ29tbWVudDIyNTIzNjIyMw==,4160723,2016-06-10T16:52:44Z,2016-06-10T16:52:44Z,MEMBER,"Thanks for your second review @shoyer ! It actually helped me to better understand the indexing logic of pandas (never too late)!
I made some updates according to your comments.
I think we're getting closer to a working feature!
","{""total_count"": 0, ""+1"": 0, ""-1"": 0, ""laugh"": 0, ""hooray"": 0, ""confused"": 0, ""heart"": 0, ""rocket"": 0, ""eyes"": 0}",,143264649
https://github.com/pydata/xarray/pull/802#issuecomment-224327201,https://api.github.com/repos/pydata/xarray/issues/802,224327201,MDEyOklzc3VlQ29tbWVudDIyNDMyNzIwMQ==,4160723,2016-06-07T15:58:49Z,2016-06-07T15:58:49Z,MEMBER,"Noted the difference in documentation.
Hope that the whole ""multi-level indexing"" section is clear enough, not sure if it's proper English.
","{""total_count"": 0, ""+1"": 0, ""-1"": 0, ""laugh"": 0, ""hooray"": 0, ""confused"": 0, ""heart"": 0, ""rocket"": 0, ""eyes"": 0}",,143264649
https://github.com/pydata/xarray/pull/802#issuecomment-224104390,https://api.github.com/repos/pydata/xarray/issues/802,224104390,MDEyOklzc3VlQ29tbWVudDIyNDEwNDM5MA==,4160723,2016-06-06T22:11:09Z,2016-06-06T22:11:09Z,MEMBER,"That behavior looks good enough to me too! It is indeed already quite flexible :-).
Do you think that we really need to handle `data.loc['a', 0]` if `data` is 2 or higher dimensional? We would also have to handle the case `data.loc[{'one': 'a', 'two': 0}]`...
Having to explicitly write `data.loc[('a', 0), :]` or `data.loc[('a', 0), ...]` seems fine to me (at least for now).
","{""total_count"": 0, ""+1"": 0, ""-1"": 0, ""laugh"": 0, ""hooray"": 0, ""confused"": 0, ""heart"": 0, ""rocket"": 0, ""eyes"": 0}",,143264649
https://github.com/pydata/xarray/pull/802#issuecomment-224092354,https://api.github.com/repos/pydata/xarray/issues/802,224092354,MDEyOklzc3VlQ29tbWVudDIyNDA5MjM1NA==,4160723,2016-06-06T21:21:29Z,2016-06-06T21:21:29Z,MEMBER,"```
>>> index = pd.MultiIndex.from_product((list('abc'), range(3)))
>>> index.names = ('one', 'two')
>>> data = xr.DataArray(range(9), [('x', index)])
>>> data
array([0, 1, 2, 3, 4, 5, 6, 7, 8])
Coordinates:
* x (x) object ('a', 0) ('a', 1) ('a', 2) ('b', 0) ('b', 1) ...
```
Example using a tuple of scalar/tuple/list/slice labels for each level:
```
>>> data.sel(x=('a', (0, 1)))
array([0, 1])
Coordinates:
* x (x) object ('a', 0) ('a', 1)
```
Example using a list of several combinations of multi-index labels:
```
>>> data.sel(x=[('a', 0), ('b', 1), ('c', 1)])
array([0, 4, 7])
Coordinates:
* x (x) object ('a', 0) ('b', 1) ('c', 1)
```
All the following examples raise an error:
```
>>> data.sel(x=(('a', 0), ('b', 1), ('c', 1)))
>>> data.sel(x=['a', (0, 1)])
>>> data.sel(x=[['a', 0], ['b', 1], ['c', 1]])
```
Note that after verification, pandas has the same behavior for all of the examples shown here.
","{""total_count"": 0, ""+1"": 0, ""-1"": 0, ""laugh"": 0, ""hooray"": 0, ""confused"": 0, ""heart"": 0, ""rocket"": 0, ""eyes"": 0}",,143264649
https://github.com/pydata/xarray/pull/802#issuecomment-223921363,https://api.github.com/repos/pydata/xarray/issues/802,223921363,MDEyOklzc3VlQ29tbWVudDIyMzkyMTM2Mw==,4160723,2016-06-06T10:22:49Z,2016-06-06T10:22:49Z,MEMBER,"Thanks for the review @shoyer !
I made some updates according to your comments.
A possible remaining issue is that using a tuple of tuples, lists or slices exactly behaves like pandas (it calls `get_locs`) while a nested list can still be used to select couples of multi-index labels (it calls `get_indexer`). Should we allow only one of two behaviors, or keep both (and mention it in the docs)?
","{""total_count"": 0, ""+1"": 0, ""-1"": 0, ""laugh"": 0, ""hooray"": 0, ""confused"": 0, ""heart"": 0, ""rocket"": 0, ""eyes"": 0}",,143264649
https://github.com/pydata/xarray/pull/802#issuecomment-222544618,https://api.github.com/repos/pydata/xarray/issues/802,222544618,MDEyOklzc3VlQ29tbWVudDIyMjU0NDYxOA==,4160723,2016-05-30T19:30:03Z,2016-05-30T19:30:03Z,MEMBER,"I finally managed to add some tests and docs.
Two more comments:
- Index replacement: if the multi-index has unnamed levels, the chosen name for the replaced index (if any) is `_unnamed_level` (`old_dim` is the name of the replaced multi-index dimension).
Not sure whether or not it is really necessary to track the index level number. Single indexes returned by `get_loc_level` don't keep that information. Anyway, it is always better to set explicit names for the index levels.
- Indexing on multi-index now also works with nested tuples (#850).
@shoyer I think that it is ready for review. I successfully run the tests on my local branch. Currently, CI tests seem broken for some reason I don't know.
","{""total_count"": 0, ""+1"": 0, ""-1"": 0, ""laugh"": 0, ""hooray"": 0, ""confused"": 0, ""heart"": 0, ""rocket"": 0, ""eyes"": 0}",,143264649
https://github.com/pydata/xarray/pull/802#issuecomment-206445614,https://api.github.com/repos/pydata/xarray/issues/802,206445614,MDEyOklzc3VlQ29tbWVudDIwNjQ0NTYxNA==,4160723,2016-04-06T16:12:44Z,2016-04-06T16:12:44Z,MEMBER,"I hope to have some time next week to work again on this PR.
@tippetts You can see in #719 a few comments about saving/reading xarray data objects with multi-index to/from netCDF. I also looking forward to see this feature implemented - actually I need it for another project that uses xarray - so maybe I'll find some time in the next couple of weeks to start a new PR on this.
","{""total_count"": 0, ""+1"": 0, ""-1"": 0, ""laugh"": 0, ""hooray"": 0, ""confused"": 0, ""heart"": 0, ""rocket"": 0, ""eyes"": 0}",,143264649
https://github.com/pydata/xarray/pull/802#issuecomment-201389147,https://api.github.com/repos/pydata/xarray/issues/802,201389147,MDEyOklzc3VlQ29tbWVudDIwMTM4OTE0Nw==,4160723,2016-03-25T17:56:51Z,2016-03-25T17:56:51Z,MEMBER,"Unless you see any other issues, I think that this feature doesn't need more development for now.
I'll be back next week to finish this PR (write some tests and doc).
","{""total_count"": 0, ""+1"": 0, ""-1"": 0, ""laugh"": 0, ""hooray"": 0, ""confused"": 0, ""heart"": 0, ""rocket"": 0, ""eyes"": 0}",,143264649
https://github.com/pydata/xarray/pull/802#issuecomment-201370448,https://api.github.com/repos/pydata/xarray/issues/802,201370448,MDEyOklzc3VlQ29tbWVudDIwMTM3MDQ0OA==,4160723,2016-03-25T17:10:40Z,2016-03-25T17:10:40Z,MEMBER,"After refactoring a bit, `da.loc[{'band': 'foo'}, :]` and `da.loc[{'band': 'foo'}, ...]` now work as expected.
`da.loc[{'band': 'foo'}]` still raises a `KeyError`. Although it is possible to catch this exception, it still remains ambiguous so it is probably better to do nothing.
","{""total_count"": 0, ""+1"": 0, ""-1"": 0, ""laugh"": 0, ""hooray"": 0, ""confused"": 0, ""heart"": 0, ""rocket"": 0, ""eyes"": 0}",,143264649
https://github.com/pydata/xarray/pull/802#issuecomment-201302454,https://api.github.com/repos/pydata/xarray/issues/802,201302454,MDEyOklzc3VlQ29tbWVudDIwMTMwMjQ1NA==,4160723,2016-03-25T14:17:29Z,2016-03-25T14:17:29Z,MEMBER,"I followed your suggestions.
Two more comments (not critical issues I think) :
- Multi-index level drop only works when a dict is provided for a dimension, i.e., `da.sel(band_wavenumber='foo')` still returns the full `pandas.MultiIndex`. This would require for `indexing.convert_label_indexer` to return an updated index also when `label` is not dict-like, which is not that straightforward I think.
- There is a potential conflict when providing a dictionary to `DataArray.loc`, it may be interpreted either as a mapping of dimensions / labels or a mapping of index levels / labels for the 1st dimension. For now, the second option is not handled, e.g., `da.loc[{'band': 'foo'}]` raises a `KeyError`.
In summary, `da.loc[{'band_wavenumber': {'band': 'foo'}}]` returns a DataArray with updated index and coordinate / dimension name, `da.loc['foo']` returns a DataArray with the full multi-index, and `da.loc[{'band': 'foo'}]` raises a `KeyError`. Three different results for the same operation, although I think that the first one is more explicit and better.
","{""total_count"": 0, ""+1"": 0, ""-1"": 0, ""laugh"": 0, ""hooray"": 0, ""confused"": 0, ""heart"": 0, ""rocket"": 0, ""eyes"": 0}",,143264649