pandas-dev/pandas · error · TypeError
Conversion to arrow with subtype '{self.dtype.subtype}' is n
Error message
Conversion to arrow with subtype '{self.dtype.subtype}' is not supported What it means
Raised by IntervalArray.__arrow_array__ when pyarrow.from_numpy_dtype(self.dtype.subtype) raises TypeError. PyArrow does not know how to map the interval's endpoint numpy dtype (e.g. certain datetime64 resolutions, object, or category) onto an arrow type. The conversion is unsupported at the subtype level.
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 71959b8cb9)
Solutions
- Cast the IntervalArray to a subtype Arrow supports: arr.astype('interval[float64]') or 'interval[int64]' before pa.array(...).
- Convert to plain tuples via arr.to_tuples() and store as a struct array instead of an arrow extension type.
- Drop timezone/period metadata from the endpoint dtype prior to conversion.
Example fix
# before
import pyarrow as pa
pa.array(interval_arr) # subtype datetime64[ns, tz]
# after
pa.array(interval_arr.astype('interval[datetime64[ns]]')) Defensive patterns
Strategy: validation
Validate before calling
import pyarrow as pa
def arrow_compatible_subtype(subtype):
try:
pa.from_numpy_dtype(subtype)
return True
except TypeError:
return False Type guard
def is_arrow_compatible_interval(arr) -> bool:
import pyarrow as pa
try:
pa.from_numpy_dtype(arr.dtype.subtype)
return True
except TypeError:
return False Try / catch
try:
return pa.array(arr)
except TypeError as e:
if 'subtype' in str(e):
return pa.array(arr.astype('interval[float64]')) Prevention
- Cast interval subtypes to arrow-supported kinds before pa.array(...).
- Use arr.to_tuples() and a struct type for unsupported subtypes.
- Document which subtypes your Arrow sink accepts.
When it happens
Trigger: Calling pa.array(interval_array) or df.convert_dtypes(dtype_backend='pyarrow') on an IntervalArray whose subtype is, e.g., datetime64[ns, tz], Period, or another arrow-foreign dtype.
Common situations: Moving interval data into Arrow/Parquet for interoperability; subtypes produced by complex time-series pipelines that Arrow's type system does not directly represent.
Related errors
- Not supported to convert IntervalArray to type with differen
- Not supported to convert IntervalArray to '{type}' type
- Invalid side: {side}. Side must be one of 'left', 'right', '
- invalid normalization form
- replace is not supported with a re.Pattern, callable repl, c
AI-assisted analysis of pandas-dev/pandas@71959b8cb9 (2026-08-07).
Data as JSON: /api/errors/ee20dc3ce1d2e40b.
Report an issue: GitHub.