pandas-dev/pandas · error · NotImplementedError
interpolate is not implemented for dtype=
Error message
interpolate is not implemented for dtype={self.dtype} What it means
When interpolate falls back to the numpy-based path (non-fast-path method/limit/area settings), only float (kind 'f') and integer (kind 'iu') dtypes have a to_numpy conversion defined. Any other numeric-ish dtype (e.g. decimal[pyarrow]) hits the else branch and raises NotImplementedError. This complements error 154 by catching exotic numeric dtypes that passed _is_numeric but lack a numpy view path.
Solutions
- Cast to float64 before interpolating: s.astype('float64').interpolate(...).
- Use the default fast path (method='linear', no limit/limit_area) which stays inside pyarrow for numeric types.
- Fall back to .ffill()/.bfill() for non-float numeric dtypes where precision loss is unacceptable.
Example fix
// before
s = pd.Series([Decimal("1"), None, Decimal("3")], dtype="decimal128(8,2)[pyarrow]")
s.interpolate(method="linear")
// after
s.astype("float64").interpolate(method="linear") Defensive patterns
Strategy: fallback
Validate before calling
def safe_interpolate_fallback(s, **kw):
if s.dtype.kind not in "iu":
# only float/int have a numpy fallback path
s = s.astype("float64")
return s.interpolate(**kw) Type guard
def dtype_has_numpy_view(dtype) -> bool:
return dtype.kind in {"f", "i", "u"} Try / catch
try:
s.interpolate(method="linear")
except NotImplementedError:
s.astype("float64").interpolate(method="linear") Prevention
- Cast decimal/exotic numeric types to float64 before non-default interpolate methods.
- Prefer the default fast-path interpolate for pyarrow numeric types.
When it happens
Trigger: Calling .interpolate(method='slinear') or any non-default method on a decimal[pyarrow] or other non-float/int numeric ArrowExtensionArray.
Common situations: Decimal128[pyarrow] columns; future numeric pyarrow types that pandas recognizes as numeric but cannot convert cheaply.
Related errors
- Cannot interpolate with
- Converting strings to
- {pa_type}
- does not support reshape as backed by a 1D…
- ambiguous is not supported.
AI-assisted analysis of pandas-dev/pandas@3b7651241d (2026-08-11).
Data as JSON: /api/errors/d8f1b1bbb16aa82d.
Report an issue: GitHub.
Appendix: source
Thrown at pandas/core/arrays/arrow/array.py:3198
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":
data = self.to_numpy(dtype="f8", na_value=0.0)
else:
raise NotImplementedError(
f"interpolate is not implemented for dtype={self.dtype}"
)
missing.interpolate_2d_inplace(
data,
method=method,
axis=0,
index=index,
limit=limit,
limit_direction=limit_direction,
limit_area=limit_area,
mask=mask,
**kwargs,
)
return self._from_pyarrow_array(self._box_pa_array(pa.array(data, mask=mask)))
@classmethod
def _if_else(View on GitHub (pinned to 3b7651241d)