pandas-dev/pandas · error · TypeError
`other` must be Interval-like, got {type(other).__name__}
Error message
`other` must be Interval-like, got {type(other).__name__} What it means
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.
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 71959b8cb9)
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.
Example fix
# before arr = pd.arrays.IntervalArray.from_tuples([(0, 2), (3, 5)]) arr.overlaps(1) # after arr.overlaps(pd.Interval(1, 4, closed='right'))
Defensive patterns
Strategy: type-guard
Validate before calling
def overlaps_arg(value, closed):
if isinstance(value, pd.Interval):
return value
if isinstance(value, (tuple, list)) and len(value) == 2:
return pd.Interval(value[0], value[1], closed=closed)
raise TypeError('overlaps expects an Interval or a (left, right) pair') Type guard
def is_single_interval(value) -> bool:
return isinstance(value, pd.Interval) Prevention
- 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.
When it happens
Trigger: Calling arr.overlaps(0.5), arr.overlaps([0,1]), or arr.overlaps('a') where arr is an IntervalArray.
Common situations: 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.
Related errors
- 'value' should be an interval type, got {type(value)} instea
- can only insert Interval objects and NA into an IntervalArra
- Not supported to convert IntervalArray to '{type}' type
- {func_name} requires a Series, Index, ExtensionArray, np.nda
- func is expected but received {} in **kwargs.
AI-assisted analysis of pandas-dev/pandas@71959b8cb9 (2026-08-07).
Data as JSON: /api/errors/6a05ad7f5c9a4442.
Report an issue: GitHub.