pandas-dev/pandas · error · TypeError
`other` must be Interval-like, got
Error message
`other` must be Interval-like, got {type(other).__name__} What it means
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.
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.
Example fix
// before arr.overlaps(2) // after arr.overlaps(pd.Interval(1, 3, closed=arr.closed))
Defensive patterns
Strategy: type-guard
Validate before calling
import pandas as pd
def as_interval_for_overlaps(v, closed):
if isinstance(v, pd.Interval):
return v
raise TypeError('overlaps requires a scalar pandas.Interval') Type guard
import pandas as pd
def is_scalar_interval(v):
return isinstance(v, pd.Interval) Prevention
- 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.
When it happens
Trigger: arr.overlaps(5); arr.overlaps('x'); arr.overlaps([1, 2]); passing a scalar point or a plain tuple/list.
Common situations: Passing a point instead of an interval; confusing overlaps with contains; passing a tuple in place of an Interval.
Related errors
- can only insert Interval objects and NA into an…
- Cannot cast to dtype
- Cannot convert to ; subtypes are incompatible
- Cannot set float NaN to integer-backed IntervalArray
- (...) must be called with a collection of some kind, was…
AI-assisted analysis of pandas-dev/pandas@3b7651241d (2026-08-11).
Data as JSON: /api/errors/6a05ad7f5c9a4442.
Report an issue: GitHub.
Appendix: source
Thrown at pandas/core/arrays/interval.py:1397
>>> intervals.overlaps(pd.Interval(0.5, 1.5))
array([ True, True, False])
Intervals that share closed endpoints overlap:
>>> intervals.overlaps(pd.Interval(1, 3, closed="left"))
array([ True, True, True])
Intervals that only have an open endpoint in common do not overlap:
>>> intervals.overlaps(pd.Interval(1, 2, closed="right"))
array([False, True, False])
"""
if isinstance(other, (IntervalArray, ABCIntervalIndex)):
raise NotImplementedError
if not isinstance(other, Interval):
msg = f"`other` must be Interval-like, got {type(other).__name__}"
raise TypeError(msg)
# equality is okay if both endpoints are closed (overlap at a point)
op1 = le if (self.closed_left and other.closed_right) else lt
op2 = le if (other.closed_left and self.closed_right) else lt
# overlaps is equivalent negation of two interval being disjoint:
# disjoint = (A.left > B.right) or (B.left > A.right)
# (simplifying the negation allows this to be done in less operations)
return op1(self.left, other.right) & op2(other.left, self.right)
# ---------------------------------------------------------------------
@property
def closed(self) -> IntervalClosedType:
"""
String describing the inclusive side the intervals.
Either ``left``, ``right``, ``both`` or ``neither``.View on GitHub (pinned to 3b7651241d)