{"record":{"id":"6a05ad7f5c9a4442","repo":"pandas-dev/pandas","slug":"other-must-be-interval-like-got-type-other","errorCode":null,"errorMessage":"`other` must be Interval-like, got {type(other).__name__}","messagePattern":"`other` must be Interval-like, got (.+?)","errorType":"validation","errorClass":"TypeError","httpStatus":null,"severity":"error","filePath":"pandas/core/arrays/interval.py","lineNumber":1397,"sourceCode":"\n        >>> intervals.overlaps(pd.Interval(0.5, 1.5))\n        array([ True,  True, False])\n\n        Intervals that share closed endpoints overlap:\n\n        >>> intervals.overlaps(pd.Interval(1, 3, closed=\"left\"))\n        array([ True,  True, True])\n\n        Intervals that only have an open endpoint in common do not overlap:\n\n        >>> intervals.overlaps(pd.Interval(1, 2, closed=\"right\"))\n        array([False,  True, False])\n        \"\"\"\n        if isinstance(other, (IntervalArray, ABCIntervalIndex)):\n            raise NotImplementedError\n        if not isinstance(other, Interval):\n            msg = f\"`other` must be Interval-like, got {type(other).__name__}\"\n            raise TypeError(msg)\n\n        # equality is okay if both endpoints are closed (overlap at a point)\n        op1 = le if (self.closed_left and other.closed_right) else lt\n        op2 = le if (other.closed_left and self.closed_right) else lt\n\n        # overlaps is equivalent negation of two interval being disjoint:\n        # disjoint = (A.left > B.right) or (B.left > A.right)\n        # (simplifying the negation allows this to be done in less operations)\n        return op1(self.left, other.right) & op2(other.left, self.right)\n\n    # ---------------------------------------------------------------------\n\n    @property\n    def closed(self) -> IntervalClosedType:\n        \"\"\"\n        String describing the inclusive side the intervals.\n\n        Either ``left``, ``right``, ``both`` or ``neither``.","sourceCodeStart":1379,"sourceCodeEnd":1415,"githubUrl":"https://github.com/pandas-dev/pandas/blob/3b7651241d4da534b3559b60ef128e1c34f54116/pandas/core/arrays/interval.py#L1379-L1415","documentation":"Raised in IntervalArray.overlaps when 'other' is neither an IntervalArray/IntervalIndex (which separately raises NotImplementedError) nor a scalar pandas.Interval. Only a scalar Interval is supported as 'other' for vectorized overlap checks.","triggerScenarios":"arr.overlaps(5); arr.overlaps('x'); arr.overlaps([1, 2]); passing a scalar point or a plain tuple/list.","commonSituations":"Passing a point instead of an interval; confusing overlaps with contains; passing a tuple in place of an Interval.","solutions":["Wrap as a scalar Interval: arr.overlaps(pd.Interval(1, 2, closed=arr.closed)).","Use arr.contains(point) if you want point-in-interval membership instead of overlap.","For interval-vs-interval overlap arrays, iterate or implement manually."],"exampleFix":"// before\narr.overlaps(2)\n// after\narr.overlaps(pd.Interval(1, 3, closed=arr.closed))","handlingStrategy":"type-guard","validationCode":"import pandas as pd\n\ndef as_interval_for_overlaps(v, closed):\n    if isinstance(v, pd.Interval):\n        return v\n    raise TypeError('overlaps requires a scalar pandas.Interval')","typeGuard":"import pandas as pd\n\ndef is_scalar_interval(v):\n    return isinstance(v, pd.Interval)","tryCatchPattern":null,"preventionTips":["Pass scalar pandas.Interval objects to overlaps.","Use contains(point) for point-in-interval membership, not overlaps.","Match the Interval's closed to the array's closed for consistent comparisons."],"tags":["interval-array","overlaps","type-check"],"backgroundTag":null,"analyzedSha":"3b7651241d4da534b3559b60ef128e1c34f54116","analyzedAt":"2026-08-11T22:10:44.015Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}