issues: 906175200
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 |
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
906175200 | MDExOlB1bGxSZXF1ZXN0NjU3MjA1NTM2 | 5402 | `dt.to_pytimedelta` to allow arithmetic with cftime objects | 20629530 | open | 0 | 1 | 2021-05-28T22:48:50Z | 2022-06-09T14:50:16Z | CONTRIBUTOR | 0 | pydata/xarray/pulls/5402 |
When playing with cftime objects a problem I encountered many times is that I can sub two arrays and them add it back to another. Subtracting to cftime datetime arrays result in an array of Example: ```python import xarray as xr da = xr.DataArray(xr.cftime_range('1900-01-01', freq='D', periods=10), dims=('time',)) An array of timedelta64[ns]dt = da - da[0] da[-1] + dt # Fails ``` However, if the two arrays were of 'O' dtype, then the subtraction would be made by This solution here adds a The user still has to check if the data is in cftime or numpy to adapt the operation (calling Also, this doesn't work with dask arrays because loading a dask array triggers the variable constructor and thus recasts the array of I realize I maybe should have opened an issue before, but I had this idea and it all rushed along. |
{ "url": "https://api.github.com/repos/pydata/xarray/issues/5402/reactions", "total_count": 0, "+1": 0, "-1": 0, "laugh": 0, "hooray": 0, "confused": 0, "heart": 0, "rocket": 0, "eyes": 0 } |
13221727 | pull |