{"record":{"id":"e9049fb46c19a5f9","repo":"pandas-dev/pandas","slug":"cannot-interpolate-with-self-dtype-dtype","errorCode":null,"errorMessage":"Cannot interpolate with {self.dtype} dtype","messagePattern":"Cannot interpolate with (.+?) dtype","errorType":"validation","errorClass":"TypeError","httpStatus":null,"severity":"error","filePath":"pandas/core/arrays/arrow/array.py","lineNumber":3152,"sourceCode":"\n    def interpolate(\n        self,\n        *,\n        method: InterpolateOptions,\n        axis: int,\n        index,\n        limit,\n        limit_direction,\n        limit_area,\n        copy: bool,\n        **kwargs,\n    ) -> Self:\n        \"\"\"\n        See NDFrame.interpolate.__doc__.\n        \"\"\"\n        # NB: we return type(self) even if copy=False\n        if not self.dtype._is_numeric:\n            raise TypeError(f\"Cannot interpolate with {self.dtype} dtype\")\n\n        if (\n            method == \"linear\"\n            and limit_area is None\n            and limit is None\n            and limit_direction == \"forward\"\n        ):\n            values = self._pa_array.combine_chunks()\n            na_value = pa.array([None], type=values.type)\n            y_diff_2 = pc.fill_null_backward(pc.pairwise_diff_checked(values, period=2))\n            prev_values = pa.concat_arrays([na_value, values[:-2], na_value])\n            interps = pc.add_checked(prev_values, pc.divide_checked(y_diff_2, 2))\n            return self._from_pyarrow_array(pc.coalesce(self._pa_array, interps))\n\n        mask = self.isna()\n        if self.dtype.kind == \"f\":\n            data = self._pa_array.to_numpy()\n        elif self.dtype.kind in \"iu\":","sourceCodeStart":3134,"sourceCodeEnd":3170,"githubUrl":"https://github.com/pandas-dev/pandas/blob/71959b8cb9b2459c16e14b34f28b178ccfe14735/pandas/core/arrays/arrow/array.py#L3134-L3170","documentation":"Raised by ArrowExtensionArray.interpolate when the dtype is not numeric (`self.dtype._is_numeric` is False). Interpolation only makes sense over a numeric domain, so non-numeric arrow dtypes are rejected upfront.","triggerScenarios":"Calling `Series.interpolate()` (or DataFrame.interpolate on a column) backed by a non-numeric pyarrow dtype — e.g. `string[pyarrow]`, `bool[pyarrow]`, or binary arrow types.","commonSituations":"Applying interpolate to all columns indiscriminately, or after a column's dtype was inferred as string rather than numeric.","solutions":["Skip/Exclude non-numeric columns before calling interpolate (e.g. `df.select_dtypes('number').interpolate()`).","Convert the column to a numeric arrow dtype if its values are actually numeric: `s.astype('float64[pyarrow]').interpolate(...)`.","Use forward/backward fill (`.ffill()`) for non-numeric columns instead of interpolation."],"exampleFix":"// before\ns = pd.Series([\"1\", None, \"3\"], dtype=\"string[pyarrow]\")\ns.interpolate()\n\n// after\ns.astype(\"float64[pyarrow]\").interpolate(method=\"linear\")","handlingStrategy":"type-guard","validationCode":"def can_interpolate(arr) -> bool:\n    return bool(getattr(arr.dtype, \"_is_numeric\", False))","typeGuard":"def is_numeric_arrow_dtype(dtype) -> bool:\n    return bool(getattr(dtype, \"_is_numeric\", False))","tryCatchPattern":"try:\n    s.interpolate()\nexcept TypeError as e:\n    if \"Cannot interpolate with\" in str(e):\n        s.astype(\"float64[pyarrow]\").interpolate()\n    else:\n        raise","preventionTips":["Filter to numeric columns before calling interpolate.","Use ffill/bfill for non-numeric columns with missing values.","Annotate columns with semantic type to drive generic missing-value strategy."],"tags":["arrow","interpolate","dtype","numeric"],"analyzedSha":"71959b8cb9b2459c16e14b34f28b178ccfe14735","analyzedAt":"2026-08-07T01:30:20.476Z","schemaVersion":2},"datasetVersion":"2026-08-07T03:17:09.362Z"}