home / github / issue_comments

Menu
  • Search all tables
  • GraphQL API

issue_comments: 545155786

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/3432#issuecomment-545155786 https://api.github.com/repos/pydata/xarray/issues/3432 545155786 MDEyOklzc3VlQ29tbWVudDU0NTE1NTc4Ng== 6213168 2019-10-22T21:07:19Z 2019-10-22T21:07:19Z MEMBER

Not a regression. I've gone back as far as xarray 0.12 and pandas 0.19 and it's always been like this. I agree it's bad and needs to be fixed though.

The issue is inherited straight from pandas: ```python

df = stacked.test.to_pandas() df

individuals c d
subtissues e f e f genes
a 1 2 3 4 b 1 2 3 4

df.iloc[:, 1]

genes a 2 b 2 Name: (c, f), dtype: int64 ``` I'm not sure if we should write an ad-hoc object in xarray for scalar multiindices.

The alternative is to think of a more systematic solution in pandas, which likely implies creating an ad-hoc subclass of tuple which is basically a pickle-able namedtuple. It must be a subclass of tuple otherwise it will break things for a lot of people around the world (the userbase of pandas is MUCH larger than xarray's). And it must be serializable for obvious reasons.

In both cases, the size of this change is very large.

The third and significantly easier option is that, on sel/isel, xarray should automatically unstack any scalar slices of a multiindex. Meaning that the 'observations' coord would simply disappear, leaving only 'individuals' and 'subtissues'. However, It would carry the problem that, if one cuts a scalar slice and a vector slice from the dimension, he won't be able to concatenate them back together.

@shoyer what's your opinion?

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