{"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":"exception","errorClass":"TypeError","httpStatus":null,"severity":"error","filePath":"pandas/core/arrays/arrow/array.py","lineNumber":3177,"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":3159,"sourceCodeEnd":3195,"githubUrl":"https://github.com/pandas-dev/pandas/blob/3b7651241d4da534b3559b60ef128e1c34f54116/pandas/core/arrays/arrow/array.py#L3159-L3195","documentation":"interpolate() requires numeric data: the method's math (pairwise_diff, divide_checked, or the missing.interpolate_2d_inplace fallback) is undefined for non-numeric dtypes. The guard at the top refuses any dtype whose _is_numeric is False, raising TypeError with the offending dtype.","triggerScenarios":"Calling .interpolate() on a string[pyarrow], binary[pyarrow], bool[pyarrow], or categorical-backed-by-arrow Series.","commonSituations":"Applying interpolate() to a whole DataFrame containing string columns; expecting interpolate to forward-fill text data.","solutions":["Use .fillna(method='ffill')/.ffill() for non-numeric columns instead of .interpolate().","Select only numeric columns: df.select_dtypes(include='number').interpolate().","Cast the column to a numeric dtype if it actually contains numbers stored as strings."],"exampleFix":"// before\ns = pd.Series([\"1\", None, \"3\"], dtype=\"string[pyarrow]\")\ns.interpolate()\n// after\ns = pd.Series([1.0, None, 3.0], dtype=\"double[pyarrow]\")\ns.interpolate()","handlingStrategy":"validation","validationCode":"def safe_interpolate(s, **kw):\n    if not getattr(s.dtype, \"_is_numeric\", False):\n        raise TypeError(f\"interpolate needs numeric dtype, got {s.dtype}\")\n    return s.interpolate(**kw)","typeGuard":"def is_numeric_dtype_obj(dtype) -> bool:\n    return bool(getattr(dtype, \"_is_numeric\", False))","tryCatchPattern":"try:\n    s.interpolate()\nexcept TypeError:\n    s.ffill()  # non-numeric fallback","preventionTips":["Run interpolate only on numeric columns.","Use ffill/bfill for non-numeric gap filling."],"tags":["pyarrow","interpolate","non-numeric","typeerror"],"backgroundTag":null,"analyzedSha":"3b7651241d4da534b3559b60ef128e1c34f54116","analyzedAt":"2026-08-11T22:10:44.015Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}