issues: 686461572
This data as json
id | node_id | number | title | user | state | locked | assignee | milestone | comments | created_at | updated_at | closed_at | author_association | active_lock_reason | draft | pull_request | body | reactions | performed_via_github_app | state_reason | repo | type |
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
686461572 | MDU6SXNzdWU2ODY0NjE1NzI= | 4378 | Plotting when Interval coordinate is timedelta-based | 500246 | open | 0 | 2 | 2020-08-26T16:36:27Z | 2022-04-18T21:55:15Z | CONTRIBUTOR | Is your feature request related to a problem? Please describe. The xarray plotting interface supports coordinates containing ```python import numpy as np import pandas as pd import xarray as xr da = xr.DataArray( np.arange(10), dims=("x",), coords={"x": [pd.Interval(i, i+1) for i in range(10)]}) da.plot() # works da = xr.DataArray( np.arange(10), dims=("x",), coords={"x": [pd.Interval( d-pd.Timestamp("2000-01-01"), d-pd.Timestamp("2000-01-01")+pd.Timedelta("1H")) for d in pd.date_range("2000-01-01", "2000-01-02", 10)]}) da.plot() # fails ``` The latter fails with:
This error message is somewhat confusing, because the coordinates are "dates of type (...) pd.Interval", but perhaps a timedelta is not considered a date. Describe the solution you'd like I would like that I can use the xarray plotting interface for any pandas.Interval coordinate, including Describe alternatives you've considered I'll "manually" calculate the midpoints and use those as a timedelta coordinate instead. Additional context It seems that regular timedeltas aren't really supported either, although they don't cause an error message, they rather produce incorrect results. There's probably a related issue somewhere, but I can't find it now. |
{ "url": "https://api.github.com/repos/pydata/xarray/issues/4378/reactions", "total_count": 0, "+1": 0, "-1": 0, "laugh": 0, "hooray": 0, "confused": 0, "heart": 0, "rocket": 0, "eyes": 0 } |
13221727 | issue |