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/4579#issuecomment-1259615513,https://api.github.com/repos/pydata/xarray/issues/4579,1259615513,IC_kwDOAMm_X85LFDUZ,4160723,2022-09-27T14:45:19Z,2022-09-27T14:46:41Z,MEMBER,"Perhaps Xarray has been too clever so far regarding how it handles pandas objects passed directly as coordinate data? `pandas.MultiIndex` objects are handled in a specific way too, which is often hard to deal with.
Expanding on @max-sixty's suggestion, we could:
- treat all coordinate data as duck arrays, i.e., in the example above handle `da1` just like `da2` (no more special cases for pandas objects)
- provide an `xarray.indexes.PandasIntervalIndex` wrapper, which would inherit from `xarray.indexes.PandasIndex` with a few addtionnal options and features, e.g., like the ones @dcherian suggests in https://github.com/pydata/xarray/discussions/6783#discussioncomment-3149033
- build an interval index from an existing coordinate using , e.g., `da.set_xindex(""x"", PandasIntervalIndex, closed=""right"")`
- figure out how to assign both a coordinate and an index from an existing `pandas.IntervalIndex` object in a convenient but more explicit way
","{""total_count"": 0, ""+1"": 0, ""-1"": 0, ""laugh"": 0, ""hooray"": 0, ""confused"": 0, ""heart"": 0, ""rocket"": 0, ""eyes"": 0}",,741806260
https://github.com/pydata/xarray/issues/4579#issuecomment-726281700,https://api.github.com/repos/pydata/xarray/issues/4579,726281700,MDEyOklzc3VlQ29tbWVudDcyNjI4MTcwMA==,5635139,2020-11-12T19:12:32Z,2020-11-12T19:12:32Z,MEMBER,"Thanks for the clear issue @gerritholl . I agree — it's confusing if those two look the same.
Currently, one way of discriminating them:
```python
In [6]: da1.indexes['x']
Out[6]:
IntervalIndex([(0.0, 0.6666666666666666], (0.6666666666666666, 1.3333333333333333], (1.3333333333333333, 2.0]],
closed='right',
name='x',
dtype='interval[float64]')
In [7]: da2.indexes['x']
Out[7]:
Index([ (0.0, 0.6666666666666666],
(0.6666666666666666, 1.3333333333333333],
(1.3333333333333333, 2.0]],
dtype='object', name='x')
```
One option is to push the dtype — `'interval[float64]` vs `object` — or the Index type — `IntervalIndex` vs `Index` — values into the repr of the array:
```python
In [8]: da1
Out[8]:
array([0, 1, 2])
Coordinates:
* x (x) object (0.0, 0.6666666666666666] ... (1.3333333333333333, 2.0]
```
Could be:
```python
* x (x) interval[float64] (0.0, 0.6666666666666666] ... (1.3333333333333333, 2.0]
```
What are others thoughts?
And ref https://github.com/pydata/xarray/projects/1","{""total_count"": 0, ""+1"": 0, ""-1"": 0, ""laugh"": 0, ""hooray"": 0, ""confused"": 0, ""heart"": 0, ""rocket"": 0, ""eyes"": 0}",,741806260