You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Is your feature request related to a problem? Please describe.
The xarray plotting interface supports coordinates containing pandas.Interval iff those intervals contain numbers. It fails when those intervals contain pandas.Timedelta:
Traceback (most recent call last):
File "mwe82.py", line 18, in <module>
da.plot() # fails
File "/data/gholl/miniconda3/envs/py38/lib/python3.8/site-packages/xarray/plot/plot.py", line 446, in __call__
return plot(self._da, **kwargs)
File "/data/gholl/miniconda3/envs/py38/lib/python3.8/site-packages/xarray/plot/plot.py", line 200, in plot
return plotfunc(darray, **kwargs)
File "/data/gholl/miniconda3/envs/py38/lib/python3.8/site-packages/xarray/plot/plot.py", line 302, in line
_ensure_plottable(xplt_val, yplt_val)
File "/data/gholl/miniconda3/envs/py38/lib/python3.8/site-packages/xarray/plot/utils.py", line 551, in _ensure_plottable
raise TypeError(
TypeError: Plotting requires coordinates to be numeric or dates of type np.datetime64, datetime.datetime, cftime.datetime or pd.Interval.
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 pandas.Timestamp and pandas.Timedelta.
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.
The text was updated successfully, but these errors were encountered:
Quickly looking at the code this error message seems to not be entirely correct. That should probably be along the lines of
TypeError: Plotting requires coordinates to be numeric or dates of type
np.datetime64, datetime.datetime, cftime.datetime
- or pd.Interval.+ or pd.Interval containing one of these dtypes.
The pd.Interval are used to calculate their midpoints. Then the dtype of the midpoints is checked:
Is your feature request related to a problem? Please describe.
The xarray plotting interface supports coordinates containing
pandas.Interval
iff those intervals contain numbers. It fails when those intervals containpandas.Timedelta
: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
pandas.Timestamp
andpandas.Timedelta
.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.
The text was updated successfully, but these errors were encountered: