pandas-dev/pandas · error · TypeError
Not supported to convert IntervalArray to
Error message
Not supported to convert IntervalArray to '{type}' type What it means
Raised in IntervalArray.__arrow_array__ when the explicit 'type' is not None, does not equal the storage_type, and is not an ArrowIntervalType. Generic non-interval Arrow types are not accepted for interval data.
Solutions
- Omit the 'type' argument and let pandas infer the interval type.
- Pass a matching ArrowIntervalType if an explicit type is required.
- Convert endpoints to the desired primitive type separately if you truly need non-interval output.
Example fix
// before pyarrow.array(arr, type=pa.string()) // after pyarrow.array(arr) # let pandas infer interval type
Defensive patterns
Strategy: type-guard
Validate before calling
from pandas.core.arrays.arrow.extension_types import ArrowIntervalType
def is_valid_interval_arrow_type(t):
return t is None or isinstance(t, ArrowIntervalType) Type guard
from pandas.core.arrays.arrow.extension_types import ArrowIntervalType
def is_arrow_interval_type(t):
return isinstance(t, ArrowIntervalType) Prevention
- Omit the 'type' argument for interval data unless you pass an ArrowIntervalType.
- Do not reuse generic primitive arrow types for interval columns.
- Convert endpoints to the desired primitive type separately if non-interval output is truly needed.
When it happens
Trigger: pyarrow.array(arr, type=pa.int64()); pyarrow.array(arr, type=pa.string()); pyarrow.array(arr, type=pa.list_(pa.int64())).
Common situations: Passing a generic primitive arrow type where an interval type is required; schema reuse across non-interval columns.
Related errors
- Conversion to arrow with subtype
- Not supported to convert IntervalArray to type with…
- Expected array of boolean type, got
- ambiguous is not supported.
- is not supported
AI-assisted analysis of pandas-dev/pandas@3b7651241d (2026-08-11).
Data as JSON: /api/errors/e1b57327ba272b11.
Report an issue: GitHub.
Appendix: source
Thrown at pandas/core/arrays/interval.py:1631
storage_array.type,
len(storage_array),
[null_bitmap],
children=[storage_array.field(0), storage_array.field(1)],
)
if type is not None:
if type.equals(interval_type.storage_type):
return storage_array
elif isinstance(type, ArrowIntervalType):
# ensure we have the same subtype and closed attributes
if not type.equals(interval_type):
raise TypeError(
"Not supported to convert IntervalArray to type with "
f"different 'subtype' ({self.dtype.subtype} vs {type.subtype}) "
f"and 'closed' ({self.closed} vs {type.closed}) attributes"
)
else:
raise TypeError(
f"Not supported to convert IntervalArray to '{type}' type"
)
return pyarrow.ExtensionArray.from_storage(interval_type, storage_array)
def to_tuples(self, na_tuple: bool = True) -> np.ndarray:
"""
Return an ndarray (if self is IntervalArray) or Index \
(if self is IntervalIndex) of tuples of the form (left, right).
This method extracts the bounds of each interval as a tuple,
useful for iteration or conversion to other data structures.
Parameters
----------
na_tuple : bool, default True
If ``True``, return ``NA`` as a tuple ``(nan, nan)``. If ``False``,
just return ``NA`` as ``nan``.View on GitHub (pinned to 3b7651241d)