pandas-dev/pandas · error · TypeError
Cannot interpolate with {self.dtype} dtype
Error message
Cannot interpolate with {self.dtype} dtype What it means
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.
Source
Thrown at pandas/core/arrays/arrow/array.py:3152
def interpolate(
self,
*,
method: InterpolateOptions,
axis: int,
index,
limit,
limit_direction,
limit_area,
copy: bool,
**kwargs,
) -> Self:
"""
See NDFrame.interpolate.__doc__.
"""
# NB: we return type(self) even if copy=False
if not self.dtype._is_numeric:
raise TypeError(f"Cannot interpolate with {self.dtype} dtype")
if (
method == "linear"
and limit_area is None
and limit is None
and limit_direction == "forward"
):
values = self._pa_array.combine_chunks()
na_value = pa.array([None], type=values.type)
y_diff_2 = pc.fill_null_backward(pc.pairwise_diff_checked(values, period=2))
prev_values = pa.concat_arrays([na_value, values[:-2], na_value])
interps = pc.add_checked(prev_values, pc.divide_checked(y_diff_2, 2))
return self._from_pyarrow_array(pc.coalesce(self._pa_array, interps))
mask = self.isna()
if self.dtype.kind == "f":
data = self._pa_array.to_numpy()
elif self.dtype.kind in "iu":View on GitHub (pinned to 71959b8cb9)
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.
Example fix
// before
s = pd.Series(["1", None, "3"], dtype="string[pyarrow]")
s.interpolate()
// after
s.astype("float64[pyarrow]").interpolate(method="linear") Defensive patterns
Strategy: type-guard
Validate before calling
def can_interpolate(arr) -> bool:
return bool(getattr(arr.dtype, "_is_numeric", False)) Type guard
def is_numeric_arrow_dtype(dtype) -> bool:
return bool(getattr(dtype, "_is_numeric", False)) Try / catch
try:
s.interpolate()
except TypeError as e:
if "Cannot interpolate with" in str(e):
s.astype("float64[pyarrow]").interpolate()
else:
raise Prevention
- 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.
When it happens
Trigger: 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.
Common situations: Applying interpolate to all columns indiscriminately, or after a column's dtype was inferred as string rather than numeric.
Related errors
- Cannot interpolate with {self.dtype} dtype
- bins argument only works with numeric data.
- Column {colname} must have a numeric dtype. Found '{dtype}'
- Invalid value '{value!s}' for dtype '{self.dtype}'
- operation '{name}' not supported for dtype '{self.dtype}'
AI-assisted analysis of pandas-dev/pandas@71959b8cb9 (2026-08-07).
Data as JSON: /api/errors/e9049fb46c19a5f9.
Report an issue: GitHub.