.item() on a DataArray with dtype='datetime64[ns]' returns int
Open
Nobody has claimed this yet.
bug
upstream issue
- Dominant language
- Python
- Stars
- 4.2k
- Forks
- 1.4k
- Avg merge
- 2d 15h
- Merged PRs (30d)
- 14
Description
MCVE Code Sample
import datetime
import xarray as xr
test_da = xr.DataArray(datetime.datetime(2019, 1, 1, 1, 1))
test_da
# <xarray.DataArray ()>
# array('2019-01-01T01:01:00.000000000', dtype='datetime64[ns]')
test_da.item()
# 1546304460000000000
Expected Output
I would think it would be nice to get a datetime out of the .item() call then the nanosecond representation.
Output of xr.show_versions()
When I call xr.show_versions() i get an error but im running xarray 0.12.3
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with the MCVE in the issue using xarray 0.12.3, then trace the DataArray.item() entry point for datetime64[ns] values. Done means the call returns a datetime rather than the integer nanosecond representation, with coverage for this behavior.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- numpy, python
- Domain
- data
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Clearly specified
- Newbie friendliness
- 45/100