MCPcopy
hub / github.com/pandas-dev/pandas / _simple_new

Method _simple_new

pandas/core/arrays/datetimes.py:317–335  ·  view source on GitHub ↗
(  # type: ignore[override]
        cls,
        values: npt.NDArray[np.datetime64],
        freq: BaseOffset | None = None,
        dtype: np.dtype[np.datetime64] | DatetimeTZDtype = DT64NS_DTYPE,
    )

Source from the content-addressed store, hash-verified

315 # error: Signature of "_simple_new" incompatible with supertype "NDArrayBacked"
316 @classmethod
317 def _simple_new( # type: ignore[override]
318 cls,
319 values: npt.NDArray[np.datetime64],
320 freq: BaseOffset | None = None,
321 dtype: np.dtype[np.datetime64] | DatetimeTZDtype = DT64NS_DTYPE,
322 ) -> Self:
323 assert isinstance(values, np.ndarray)
324 assert dtype.kind == "M"
325 if isinstance(dtype, np.dtype):
326 assert dtype == values.dtype
327 assert not is_unitless(dtype)
328 else:
329 # DatetimeTZDtype. If we have e.g. DatetimeTZDtype[us, UTC],
330 # then values.dtype should be M8[us].
331 assert dtype._creso == get_unit_from_dtype(values.dtype)
332
333 result = super()._simple_new(values, dtype)
334 result._freq = freq
335 return result
336
337 @classmethod
338 def _from_sequence(cls, scalars, *, dtype=None, copy: bool = False) -> Self:

Callers 8

tz_convertMethod · 0.95
tz_localizeMethod · 0.95
_generate_rangeMethod · 0.45
astypeMethod · 0.45
_add_offsetMethod · 0.45
normalizeMethod · 0.45
stdMethod · 0.45

Calls

no outgoing calls

Tested by

no test coverage detected