home / github / issue_comments

Menu
  • Search all tables
  • GraphQL API

issue_comments: 191625512

This data as json

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/issues/767#issuecomment-191625512 https://api.github.com/repos/pydata/xarray/issues/767 191625512 MDEyOklzc3VlQ29tbWVudDE5MTYyNTUxMg== 4160723 2016-03-03T07:24:34Z 2016-03-03T07:24:34Z MEMBER

From this point of view I agree that da.sel(band_wavenumber={'band': 'bar'}) is a nicer solution! I'll follow your suggestion of returning a new pandas.Index object from convert_label_indexer.

Unless I miss a better solution, we can use pandas.MultiIndex.get_loc_level to get both the indexer and the new pandas.Index object. However, there may still be some advanced cases where it won't behave as expected. For example, selecting both the band 'bar' and a range of wavenumber values (that doesn't exactly match the range of that band)

da.sel(band_wavenumber={'band': 'bar', 'wavenumber': slice(4000, 4100.3)})`

will a-priori return a stacked DataArray with the full multi-index:

In [32]: idx = da.band_wavenumber.to_index() In [33]: idx.get_loc_level(('bar', slice(4000, 4100.3)), level=('band', 'wavenumber')) Out[33]: (array([False, False, True, True, False], dtype=bool), MultiIndex(levels=[['bar', 'foo'], [4050.2, 4050.3, 4100.1, 4100.3, 4100.5]], labels=[[0, 0], [2, 3]], names=['band', 'wavenumber']))

{
    "total_count": 0,
    "+1": 0,
    "-1": 0,
    "laugh": 0,
    "hooray": 0,
    "confused": 0,
    "heart": 0,
    "rocket": 0,
    "eyes": 0
}
  134359597
Powered by Datasette · Queries took 82.517ms · About: xarray-datasette