{"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":"exception","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/71959b8cb9b2459c16e14b34f28b178ccfe14735/pandas/core/arrays/interval.py#L1379-L1415","documentation":"Raised by IntervalArray.overlaps when 'other' is neither a pd.Interval, IntervalArray, nor IntervalIndex. The method only supports a single Interval argument; passing an IntervalArray/Index raises NotImplementedError, and any other type raises this TypeError with the offending type name.","triggerScenarios":"Calling arr.overlaps(0.5), arr.overlaps([0,1]), or arr.overlaps('a') where arr is an IntervalArray.","commonSituations":"Assuming overlaps accepts a scalar point (it does not — use .contains for that), passing a list of intervals instead of a single Interval, or forgetting to wrap endpoints.","solutions":["Wrap the argument in a single pd.Interval(left, right, closed=...) before calling .overlaps.","For element-wise overlap against another array of intervals, currently unsupported — convert to a loop or use IntervalIndex.overlaps if available.","For point-in-interval checks use arr.contains(point) instead of overlaps."],"exampleFix":"# before\narr = pd.arrays.IntervalArray.from_tuples([(0, 2), (3, 5)])\narr.overlaps(1)\n\n# after\narr.overlaps(pd.Interval(1, 4, closed='right'))","handlingStrategy":"type-guard","validationCode":"def overlaps_arg(value, closed):\n    if isinstance(value, pd.Interval):\n        return value\n    if isinstance(value, (tuple, list)) and len(value) == 2:\n        return pd.Interval(value[0], value[1], closed=closed)\n    raise TypeError('overlaps expects an Interval or a (left, right) pair')","typeGuard":"def is_single_interval(value) -> bool:\n    return isinstance(value, pd.Interval)","tryCatchPattern":null,"preventionTips":["Wrap scalar endpoints in pd.Interval before calling .overlaps.","Use .contains for point-in-interval checks.","Do not pass arrays/lists to .overlaps — it is scalar-only."],"tags":["interval-array","type-error","overlaps"],"analyzedSha":"71959b8cb9b2459c16e14b34f28b178ccfe14735","analyzedAt":"2026-08-07T01:30:20.476Z","schemaVersion":2},"datasetVersion":"2026-08-07T03:17:09.362Z"}