pydata / pydata/xarray

.item() on a DataArray with dtype='datetime64[ns]' returns int

Open
#3,256 4 comments 0 reactions 0 assignees View on GitHub

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

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. 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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.