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

Method _needs_i8_conversion

pandas/core/indexes/interval.py:626–649  ·  view source on GitHub ↗

Check if a given key needs i8 conversion. Conversion is necessary for Timestamp, Timedelta, DatetimeIndex, and TimedeltaIndex keys. An Interval-like requires conversion if its endpoints are one of the aforementioned types. Assumes that any list-like data has

(self, key)

Source from the content-addressed store, hash-verified

624 return self._engine.is_overlapping
625
626 def _needs_i8_conversion(self, key) -> bool:
627 """
628 Check if a given key needs i8 conversion. Conversion is necessary for
629 Timestamp, Timedelta, DatetimeIndex, and TimedeltaIndex keys. An
630 Interval-like requires conversion if its endpoints are one of the
631 aforementioned types.
632
633 Assumes that any list-like data has already been cast to an Index.
634
635 Parameters
636 ----------
637 key : scalar or Index-like
638 The key that should be checked for i8 conversion
639
640 Returns
641 -------
642 bool
643 """
644 key_dtype = getattr(key, "dtype", None)
645 if isinstance(key_dtype, IntervalDtype) or isinstance(key, Interval):
646 return self._needs_i8_conversion(key.left)
647
648 i8_types = (Timestamp, Timedelta, DatetimeIndex, TimedeltaIndex)
649 return isinstance(key, i8_types)
650
651 def _maybe_convert_i8(self, key):
652 """

Callers 1

_maybe_convert_i8Method · 0.95

Calls

no outgoing calls

Tested by

no test coverage detected