{"record":{"id":"e1b57327ba272b11","repo":"pandas-dev/pandas","slug":"not-supported-to-convert-intervalarray-to-type","errorCode":null,"errorMessage":"Not supported to convert IntervalArray to '{type}' type","messagePattern":"Not supported to convert IntervalArray to '(.+?)' type","errorType":"validation","errorClass":"TypeError","httpStatus":null,"severity":"error","filePath":"pandas/core/arrays/interval.py","lineNumber":1631,"sourceCode":"                storage_array.type,\n                len(storage_array),\n                [null_bitmap],\n                children=[storage_array.field(0), storage_array.field(1)],\n            )\n\n        if type is not None:\n            if type.equals(interval_type.storage_type):\n                return storage_array\n            elif isinstance(type, ArrowIntervalType):\n                # ensure we have the same subtype and closed attributes\n                if not type.equals(interval_type):\n                    raise TypeError(\n                        \"Not supported to convert IntervalArray to type with \"\n                        f\"different 'subtype' ({self.dtype.subtype} vs {type.subtype}) \"\n                        f\"and 'closed' ({self.closed} vs {type.closed}) attributes\"\n                    )\n            else:\n                raise TypeError(\n                    f\"Not supported to convert IntervalArray to '{type}' type\"\n                )\n\n        return pyarrow.ExtensionArray.from_storage(interval_type, storage_array)\n\n    def to_tuples(self, na_tuple: bool = True) -> np.ndarray:\n        \"\"\"\n        Return an ndarray (if self is IntervalArray) or Index \\\n        (if self is IntervalIndex) of tuples of the form (left, right).\n\n        This method extracts the bounds of each interval as a tuple,\n        useful for iteration or conversion to other data structures.\n\n        Parameters\n        ----------\n        na_tuple : bool, default True\n            If ``True``, return ``NA`` as a tuple ``(nan, nan)``. If ``False``,\n            just return ``NA`` as ``nan``.","sourceCodeStart":1613,"sourceCodeEnd":1649,"githubUrl":"https://github.com/pandas-dev/pandas/blob/3b7651241d4da534b3559b60ef128e1c34f54116/pandas/core/arrays/interval.py#L1613-L1649","documentation":"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.","triggerScenarios":"pyarrow.array(arr, type=pa.int64()); pyarrow.array(arr, type=pa.string()); pyarrow.array(arr, type=pa.list_(pa.int64())).","commonSituations":"Passing a generic primitive arrow type where an interval type is required; schema reuse across non-interval columns.","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."],"exampleFix":"// before\npyarrow.array(arr, type=pa.string())\n// after\npyarrow.array(arr)  # let pandas infer interval type","handlingStrategy":"type-guard","validationCode":"from pandas.core.arrays.arrow.extension_types import ArrowIntervalType\n\ndef is_valid_interval_arrow_type(t):\n    return t is None or isinstance(t, ArrowIntervalType)","typeGuard":"from pandas.core.arrays.arrow.extension_types import ArrowIntervalType\n\ndef is_arrow_interval_type(t):\n    return isinstance(t, ArrowIntervalType)","tryCatchPattern":null,"preventionTips":["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."],"tags":["interval-array","arrow","pyarrow","type"],"backgroundTag":null,"analyzedSha":"3b7651241d4da534b3559b60ef128e1c34f54116","analyzedAt":"2026-08-11T22:10:44.015Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}