pandas-dev/pandas · error · NotImplementedError
does not implement interpolate
Error message
{type(self).__name__} does not implement interpolate What it means
The base ExtensionArray.interpolate raises NotImplementedError naming the subclass: interpolation is dtype-specific (linear needs numeric ordering, time-based needs a DatetimeIndex, etc.) and the base class cannot provide a correct default. Subclasses opt in by overriding interpolate. The source notes the method must return type(self) even when copy=False.
Solutions
- Interpolate only the numeric/temporal columns: df.select_dtypes(include='number').interpolate(), or exclude the unsupported column with df.drop(columns=[...]).interpolate().
- If you own the EA, implement interpolate returning type(self) with the desired method handling.
- Use fillna (ffill/bfill) as a fallback where appropriate, since _pad_or_backfill has its own (also overridable) default.
Example fix
// before df.interpolate() # NotImplementedError on custom EA column // after df.select_dtypes(include='number').interpolate() # or fill the unsupported column separately df['custom_col'] = df['custom_col'].fillna(method='ffill')
Defensive patterns
Strategy: fallback
Validate before calling
from pandas.api.extensions import ExtensionArray
if getattr(type(arr), 'interpolate', None) is ExtensionArray.interpolate:
# base will raise; use fillna instead
out = arr.fillna(method='ffill')
else:
out = arr.interpolate(method='linear', axis=0, index=..., limit=None, limit_direction='both', limit_area=None, copy=True) Type guard
def supports_interpolate(cls) -> bool:
return getattr(cls, 'interpolate', None) is not ExtensionArray.interpolate Try / catch
try:
out = series.interpolate()
except NotImplementedError:
out = series.ffill() Prevention
- Limit interpolate() to numeric/temporal columns via select_dtypes.
- Provide an ffill/bfill fallback for unsupported EA columns.
- If you own the EA, implement interpolate to support at least method='linear'.
When it happens
Trigger: Calling Series.interpolate / DataFrame.interpolate on a column backed by an ExtensionArray whose class did not override interpolate (e.g. a custom categorical-like or string dtype). Internally pandas calls arr.interpolate(...) which hits the base NotImplemented.
Common situations: Applying df.interpolate() to a mixed-dtype frame where one non-numeric EA column lacks an interpolate override. Using interpolate(method='time') on a custom EA that only supports numeric data. Third-party dtype without interpolation support.
Related errors
- cannot perform with type
- Default 'empty' implementation is invalid for dtype=
- {dtype}
- function is not implemented for this dtype
- can only convert an array of size 1 to a Python scalar
AI-assisted analysis of pandas-dev/pandas@3b7651241d (2026-08-11).
Data as JSON: /api/errors/bf43a601da7c8462.
Report an issue: GitHub.
Appendix: source
Thrown at pandas/core/arrays/base.py:1298
Interpolating values in a FloatingArray:
>>> arr = pd.array([1.0, pd.NA, 3.0, 4.0, pd.NA, 6.0], dtype="Float64")
>>> arr.interpolate(
... method="linear",
... axis=0,
... index=pd.Index(range(len(arr))),
... limit=None,
... limit_direction="both",
... limit_area=None,
... copy=True,
... )
<FloatingArray>
[1.0, 2.0, 3.0, 4.0, 5.0, 6.0]
Length: 6, dtype: Float64
"""
# NB: we return type(self) even if copy=False
raise NotImplementedError(
f"{type(self).__name__} does not implement interpolate"
)
def _pad_or_backfill(
self,
*,
method: FillnaOptions,
limit: int | None = None,
limit_area: Literal["inside", "outside"] | None = None,
copy: bool = True,
) -> Self:
"""
Pad or backfill values, used by Series/DataFrame ffill and bfill.
This method propagates the last valid observation forward (pad/ffill)
or the next valid observation backward (backfill/bfill) to fill NaN
values.
View on GitHub (pinned to 3b7651241d)