-
-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Timedelta dt accessor does not work #3609
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
and since xarray coerces the dataarray to a Pandas Series prior accessing the requested attribute, calling
In [33]: start_t.dt.seconds
---------------------------------------------------------------------------
AttributeError Traceback (most recent call last)
<ipython-input-33-e1e0943720f8> in <module>
----> 1 start_t.dt.seconds
AttributeError: 'DatetimeAccessor' object has no attribute 'seconds' This is likely a bug in xarray.
In [16]: start_t_series.dt
Out[16]: <pandas.core.indexes.accessors.TimedeltaProperties object at 0x7f2afafd45c0>
In [17]: dt_array_series.dt
Out[17]: <pandas.core.indexes.accessors.DatetimeProperties object at 0x7f2bf7ccd320> Xarray, on the other hand, seems to be treating them the same: In [18]: dt_array.dt
Out[18]: <xarray.core.accessor_dt.DatetimeAccessor at 0x7f2afb6e8710>
In [19]: start_t.dt
Out[19]: <xarray.core.accessor_dt.DatetimeAccessor at 0x7f2afb6a20f0>
|
This is more unimplemented feature than a bug. The Timedelta functionality hasn't been implemented e.g. xarray/xarray/core/accessor_dt.py Line 204 in 2ee89c3
|
@dcherian, Thank you for chiming in! Are there any other issues with discussions about implementation for |
I think this would be a welcome feature. It seems like there should be a lot of shared code between the two accessors. |
MCVE Code Sample
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()
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
The text was updated successfully, but these errors were encountered: