-
-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
Date missing in datetime accessor #4983
Comments
Sounds reasonable. Or maybe that's not supported in cftime? cc @spencerkclark |
Yes, I agree, this seems reasonable. It's true that there is no object equivalent to I'll admit I personally have not found a need for functionality like this -- I typically prefer to use something like |
I didn't thought of using The import numpy as np
import pandas as pd
import xarray as xr
attrs = {"units": "hours since 3000-01-01"}
ds = xr.Dataset({"time": ("time", [0, 1, 2, 3], attrs)})
xr.decode_cf(ds).time.dt.time
# AttributeError: 'CFTimeIndex' object has no attribute 'time' I implemented the |
For sure, thanks for getting started on a PR! I like the more informative Regarding |
What happened:
I wonder if there is a reason, why there is no
date
attribute in the datetime accessor.What you expected to happen:
As the
time
attribute is supported I would expect the same for thedate
attributeMinimal Complete Verifiable Example:
Suggestion:
A simple addition of
in core/accessor_dt.py should do the trick. Happy to do a PR.
Anything else we need to know?:
Environment:
Output of xr.show_versions()
INSTALLED VERSIONS
commit: None
python: 3.8.6 | packaged by conda-forge | (default, Oct 7 2020, 19:08:05)
[GCC 7.5.0]
python-bits: 64
OS: Linux
OS-release: 2.6.32-754.33.1.el6.x86_64
machine: x86_64
processor: x86_64
byteorder: little
LC_ALL: None
LANG: en_US.UTF-8
LOCALE: en_US.UTF-8
libhdf5: 1.10.6
libnetcdf: 4.7.4
xarray: 0.17.0
pandas: 1.2.1
numpy: 1.20.0
scipy: 1.6.0
netCDF4: 1.5.5.1
pydap: None
h5netcdf: None
h5py: None
Nio: None
zarr: 2.6.1
cftime: 1.4.1
nc_time_axis: None
PseudoNetCDF: None
rasterio: None
cfgrib: None
iris: None
bottleneck: None
dask: 2021.02.0
distributed: 2021.02.0
matplotlib: 3.3.4
cartopy: 0.18.0
seaborn: 0.11.1
numbagg: None
pint: 0.16.1
setuptools: 49.6.0.post20210108
pip: 21.0.1
conda: None
pytest: None
IPython: 7.20.0
sphinx: None
The text was updated successfully, but these errors were encountered: