home / github / issue_comments

Menu
  • GraphQL API
  • Search all tables

issue_comments: 191239041

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-191239041 https://api.github.com/repos/pydata/xarray/issues/767 191239041 MDEyOklzc3VlQ29tbWVudDE5MTIzOTA0MQ== 4160723 2016-03-02T13:31:36Z 2016-03-02T13:31:36Z MEMBER

Thinking about this issue, I'd like to know what you think of the suggestions below before considering any pull request.

The following line code gives the same result than in my previous comment, but it is more explicit and shorter:

python da.unstack('band_wavenumber').sel(band='bar').dropna('wavenumber', how='any')

A nice shortcut to this would be adding a new xs method to DataArray and Dataset, which would be quite similar to the xs method of Pandas but here with an additional dim keyword argument:

python da.xs('bar', dim='band_wavenumber', level='band', drop_level=True)

Like Pandas, the default value of drop_level would be True. But here drop_level rather sets whether or not to apply dropna to all (unstacked) index levels of dim except the specified level.

I think that this solution is better than, e.g., directly providing index level names as arguments of the sel method. This may be confusing and there may be conflict when different dimensions have the same index level names.

Another, though less elegant, solution would be to provide dictionnaries to the sel method:

python da.sel(band_wavenumber={'band': 'bar'})

Besides this, It would be nice if the drop_level=True behavior could be applied by default to any selection (i.e., also when using loc, sel, etc.), like with Pandas. I don't know how Pandas does this (I'll look into that), but at first glance this would here imply checking for each dimension if it has a multi-index and then checking the labels for each index level.

{
    "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 0.575ms · About: xarray-datasette