MCPcopy Index your code
hub / github.com/pydata/xarray / _datetime64_via_timestamp

Function _datetime64_via_timestamp

xarray/groupers.py:67–74  ·  view source on GitHub ↗

Construct a numpy.datetime64 object through the pandas.Timestamp constructor with a specific resolution.

(unit: PDDatetimeUnitOptions, **kwargs)

Source from the content-addressed store, hash-verified

65
66
67def _datetime64_via_timestamp(unit: PDDatetimeUnitOptions, **kwargs) -> np.datetime64:
68 """Construct a numpy.datetime64 object through the pandas.Timestamp
69 constructor with a specific resolution."""
70 # TODO: when pandas 3 is our minimum requirement we will no longer need to
71 # convert to np.datetime64 values prior to passing to the DatetimeIndex
72 # constructor. With pandas < 3 the DatetimeIndex constructor does not
73 # infer the resolution from the resolution of the Timestamp values.
74 return pd.Timestamp(**kwargs).as_unit(unit).to_numpy()
75
76
77@dataclass(init=False)

Callers

nothing calls this directly

Calls 1

to_numpyMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…