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

Method _intersection

pandas/core/indexes/datetimelike.py:769–790  ·  view source on GitHub ↗

intersection specialized to the case with matching dtypes and both non-empty.

(self, other: Index, sort: bool = False)

Source from the content-addressed store, hash-verified

767 return self._wrap_range_setop(other, res_i8)
768
769 def _intersection(self, other: Index, sort: bool = False) -> Index:
770 """
771 intersection specialized to the case with matching dtypes and both non-empty.
772 """
773 other = cast("DatetimeTimedeltaMixin", other)
774
775 if self._can_range_setop(other):
776 return self._range_intersect(other, sort=sort)
777
778 if not self._can_fast_intersect(other):
779 result = Index._intersection(self, other, sort=sort)
780 # We need to invalidate the freq because Index._intersection
781 # uses _shallow_copy on a view of self._data, which will preserve
782 # self.freq if we're not careful.
783 # At this point we should have result.dtype == self.dtype
784 # and type(result) is type(self._data)
785 result = self._wrap_setop_result(other, result)
786 # error: "Index" has no attribute "_with_freq"; maybe "_with_infer"?
787 return result._with_freq(None)._with_freq("infer") # type: ignore[attr-defined]
788
789 else:
790 return self._fast_intersect(other, sort)
791
792 def _fast_intersect(self, other, sort):
793 # to make our life easier, "sort" the two ranges

Callers

nothing calls this directly

Calls 6

_can_range_setopMethod · 0.95
_range_intersectMethod · 0.95
_can_fast_intersectMethod · 0.95
_fast_intersectMethod · 0.95
_wrap_setop_resultMethod · 0.80
_with_freqMethod · 0.45

Tested by

no test coverage detected