pandas-dev/pandas · error · TypeError
Conversion to arrow with subtype
Error message
Conversion to arrow with subtype '{self.dtype.subtype}' is not supported What it means
Raised in IntervalArray.__arrow_array__ when pyarrow.from_numpy_dtype(self.dtype.subtype) raises TypeError - the interval subtype has no Arrow equivalent (e.g., object subtype, or an unsupported/unusual dtype). The conversion cannot proceed without a mappable Arrow storage type.
Solutions
- Cast the IntervalArray to a supported numeric/datetime subtype before arrow conversion: arr.astype('interval[int64]').
- Inspect arr.dtype.subtype and convert endpoints to a pyarrow-friendly numpy type first.
- Avoid object-backed intervals; build intervals from typed endpoint arrays.
Example fix
// before
pyarrow.array(obj_arr)
// after
arr = obj_arr.astype('interval[int64]')
pyarrow.array(arr) Defensive patterns
Strategy: validation
Validate before calling
import pyarrow
def arrow_subtype_supported(arr):
try:
pyarrow.from_numpy_dtype(arr.dtype.subtype)
return True
except TypeError:
return False
def to_arrow_safe(arr):
if not arrow_subtype_supported(arr):
arr = arr.astype('interval[int64]')
return pyarrow.array(arr) Try / catch
try:
pa_arr = pyarrow.array(arr)
except TypeError as e:
if 'subtype' in str(e) and 'not supported' in str(e):
arr = arr.astype('interval[int64]')
pa_arr = pyarrow.array(arr)
else:
raise Prevention
- Ensure interval endpoints are numeric or datetime before arrow conversion.
- Avoid object-backed intervals; construct from typed endpoint arrays.
- Inspect arr.dtype.subtype before pyarrow.array/ to_parquet.
When it happens
Trigger: pyarrow.array(interval_arr) where the subtype is object or unsupported; arr.__arrow_array__() on intervals whose endpoints inferred object dtype.
Common situations: Mixed-type endpoint data inferring object dtype; custom or unusual subtypes; passing intervals through pyarrow conversion (e.g., to_parquet).
Related errors
- Not supported to convert IntervalArray to
- Not supported to convert IntervalArray to type with…
- Cannot convert to ; subtypes are incompatible
- Expected array of boolean type, got
- 'value' should be a compatible interval type, got
AI-assisted analysis of pandas-dev/pandas@3b7651241d (2026-08-11).
Data as JSON: /api/errors/ee20dc3ce1d2e40b.
Report an issue: GitHub.
Appendix: source
Thrown at pandas/core/arrays/interval.py:1596
for i, left_value in enumerate(left):
if mask[i]:
result[i] = np.nan
else:
result[i] = Interval(left_value, right[i], closed)
return result
def __arrow_array__(self, type=None):
"""
Convert myself into a pyarrow Array.
"""
import pyarrow
from pandas.core.arrays.arrow.extension_types import ArrowIntervalType
try:
subtype = pyarrow.from_numpy_dtype(self.dtype.subtype)
except TypeError as err:
raise TypeError(
f"Conversion to arrow with subtype '{self.dtype.subtype}' "
"is not supported"
) from err
interval_type = ArrowIntervalType(subtype, self.closed)
storage_array = pyarrow.StructArray.from_arrays(
[
pyarrow.array(self._left, type=subtype, from_pandas=True),
pyarrow.array(self._right, type=subtype, from_pandas=True),
],
names=["left", "right"],
)
mask = self.isna()
if mask.any():
# if there are missing values, set validity bitmap also on the array level
null_bitmap = pyarrow.array(~mask).buffers()[1]
storage_array = pyarrow.StructArray.from_buffers(
storage_array.type,
len(storage_array),View on GitHub (pinned to 3b7651241d)