{"record":{"id":"ee20dc3ce1d2e40b","repo":"pandas-dev/pandas","slug":"conversion-to-arrow-with-subtype-self-dtype-subt","errorCode":null,"errorMessage":"Conversion to arrow with subtype '{self.dtype.subtype}' is not supported","messagePattern":"Conversion to arrow with subtype '(.+?)' is not supported","errorType":"exception","errorClass":"TypeError","httpStatus":null,"severity":"error","filePath":"pandas/core/arrays/interval.py","lineNumber":1596,"sourceCode":"        for i, left_value in enumerate(left):\n            if mask[i]:\n                result[i] = np.nan\n            else:\n                result[i] = Interval(left_value, right[i], closed)\n        return result\n\n    def __arrow_array__(self, type=None):\n        \"\"\"\n        Convert myself into a pyarrow Array.\n        \"\"\"\n        import pyarrow\n\n        from pandas.core.arrays.arrow.extension_types import ArrowIntervalType\n\n        try:\n            subtype = pyarrow.from_numpy_dtype(self.dtype.subtype)\n        except TypeError as err:\n            raise TypeError(\n                f\"Conversion to arrow with subtype '{self.dtype.subtype}' \"\n                \"is not supported\"\n            ) from err\n        interval_type = ArrowIntervalType(subtype, self.closed)\n        storage_array = pyarrow.StructArray.from_arrays(\n            [\n                pyarrow.array(self._left, type=subtype, from_pandas=True),\n                pyarrow.array(self._right, type=subtype, from_pandas=True),\n            ],\n            names=[\"left\", \"right\"],\n        )\n        mask = self.isna()\n        if mask.any():\n            # if there are missing values, set validity bitmap also on the array level\n            null_bitmap = pyarrow.array(~mask).buffers()[1]\n            storage_array = pyarrow.StructArray.from_buffers(\n                storage_array.type,\n                len(storage_array),","sourceCodeStart":1578,"sourceCodeEnd":1614,"githubUrl":"https://github.com/pandas-dev/pandas/blob/71959b8cb9b2459c16e14b34f28b178ccfe14735/pandas/core/arrays/interval.py#L1578-L1614","documentation":"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.","triggerScenarios":"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.","commonSituations":"Moving interval data into Arrow/Parquet for interoperability; subtypes produced by complex time-series pipelines that Arrow's type system does not directly represent.","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."],"exampleFix":"# before\nimport pyarrow as pa\npa.array(interval_arr)  # subtype datetime64[ns, tz]\n\n# after\npa.array(interval_arr.astype('interval[datetime64[ns]]'))","handlingStrategy":"validation","validationCode":"import pyarrow as pa\ndef arrow_compatible_subtype(subtype):\n    try:\n        pa.from_numpy_dtype(subtype)\n        return True\n    except TypeError:\n        return False","typeGuard":"def is_arrow_compatible_interval(arr) -> bool:\n    import pyarrow as pa\n    try:\n        pa.from_numpy_dtype(arr.dtype.subtype)\n        return True\n    except TypeError:\n        return False","tryCatchPattern":"try:\n    return pa.array(arr)\nexcept TypeError as e:\n    if 'subtype' in str(e):\n        return pa.array(arr.astype('interval[float64]'))","preventionTips":["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."],"tags":["interval-array","pyarrow","interop"],"analyzedSha":"71959b8cb9b2459c16e14b34f28b178ccfe14735","analyzedAt":"2026-08-07T01:30:20.476Z","schemaVersion":2},"datasetVersion":"2026-08-07T03:17:09.362Z"}