-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Open
Description
What is your issue?
In xarray prior to 2025.1.2 usage of np.datetime64 and datetime resulted in identical result
from datetime import datetime
import numpy as np
import xarray as xr
a = xr.DataArray(coords={'time': [np.datetime64('2020')]}, dims=['time'])
b = xr.DataArray(coords={'time': [datetime(2020,1,1)]}, dims=['time'])
print(a['time'].dtype)
print(b['time'].dtype)would yield
datetime64[ns]
datetime64[ns]From version 2025.1.2, this is no longer true, and we get
datetime64[s]
datetime64[ns]Together with the equality check failing (pandas-dev/pandas#55694), this means comparing DataArrays and Datasets is now subtly dependent on whether datetime or np.datetime64 was used to construct them.
Is this the intended behaviour? Is there a recommended way to deal with this difference beyond requiring the users to always specify np.datetime(..., 'ns')?
Metadata
Metadata
Assignees
Labels
No labels