Skip to content

Timedelta dt accessor does not work #3609

Closed
@Tillsten

Description

@Tillsten

MCVE Code Sample

# Your code here
import xarray as xr
import datetime as dt

now = dt.datetime.now()
dt_array = xr.DataArray([now + dt.timedelta(seconds=i) for i in range(10)])

dt_array.dt.second #works

start_t = dt_array - dt_array[0]
start_t.dt.second #fails

Expected Output

Last line should give me the time timedelta in seconds. Instead it raises an exception. Same for hour and minute.

Output of xr.show_versions()

INSTALLED VERSIONS ------------------ commit: None python: 3.7.3 (default, Apr 24 2019, 15:29:51) [MSC v.1915 64 bit (AMD64)] python-bits: 64 OS: Windows OS-release: 10 machine: AMD64 processor: Intel64 Family 6 Model 158 Stepping 10, GenuineIntel byteorder: little LC_ALL: None LANG: None LOCALE: None.None libhdf5: None libnetcdf: None

xarray: 0.14.0
pandas: 0.25.3
numpy: 1.17.4
scipy: 1.2.1
netCDF4: None
pydap: None
h5netcdf: None
h5py: None
Nio: None
zarr: None
cftime: None
nc_time_axis: None
PseudoNetCDF: None
rasterio: None
cfgrib: None
iris: None
bottleneck: None
dask: None
distributed: None
matplotlib: 3.1.1
cartopy: None
seaborn: None
numbagg: None
setuptools: 42.0.2.post20191203
pip: 19.1.1
conda: None
pytest: 5.0.0
IPython: 7.7.0
sphinx: 2.2.1

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions