{"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":"validation","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/3b7651241d4da534b3559b60ef128e1c34f54116/pandas/core/arrays/interval.py#L1578-L1614","documentation":"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.","triggerScenarios":"pyarrow.array(interval_arr) where the subtype is object or unsupported; arr.__arrow_array__() on intervals whose endpoints inferred object dtype.","commonSituations":"Mixed-type endpoint data inferring object dtype; custom or unusual subtypes; passing intervals through pyarrow conversion (e.g., to_parquet).","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."],"exampleFix":"// before\npyarrow.array(obj_arr)\n// after\narr = obj_arr.astype('interval[int64]')\npyarrow.array(arr)","handlingStrategy":"validation","validationCode":"import pyarrow\n\ndef arrow_subtype_supported(arr):\n    try:\n        pyarrow.from_numpy_dtype(arr.dtype.subtype)\n        return True\n    except TypeError:\n        return False\n\ndef to_arrow_safe(arr):\n    if not arrow_subtype_supported(arr):\n        arr = arr.astype('interval[int64]')\n    return pyarrow.array(arr)","typeGuard":null,"tryCatchPattern":"try:\n    pa_arr = pyarrow.array(arr)\nexcept TypeError as e:\n    if 'subtype' in str(e) and 'not supported' in str(e):\n        arr = arr.astype('interval[int64]')\n        pa_arr = pyarrow.array(arr)\n    else:\n        raise","preventionTips":["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."],"tags":["interval-array","arrow","subtype","pyarrow"],"backgroundTag":null,"analyzedSha":"3b7651241d4da534b3559b60ef128e1c34f54116","analyzedAt":"2026-08-11T22:10:44.015Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}