pandas-dev/pandas · error · TypeError
ExtensionArray.fillna does not support filling with a dict.
Error message
ExtensionArray.fillna does not support filling with a dict. Use Series.fillna instead.
What it means
Raised as a TypeError by `IntervalArray.fillna` when `value` is a dict. Dict-based filling (per-label) is a Series-level concept and is not implemented on the bare ExtensionArray. Fires at pandas/core/arrays/interval.py:899.
Source
Thrown at pandas/core/arrays/interval.py:899
values for each index. The value should not be a list. The
value(s) passed should be either Interval objects or NA/NaN.
limit : int, default None
(Not implemented yet for IntervalArray)
The maximum number of entries where NA values will be filled.
copy : bool, default True
Whether to make a copy of the data before filling. If False, then
the original should be modified and no new memory should be allocated.
For ExtensionArray subclasses that cannot do this, it is at the
author's discretion whether to ignore "copy=False" or to raise.
Returns
-------
filled : IntervalArray with NA/NaN filled
"""
if copy is False:
raise NotImplementedError
if isinstance(value, dict):
raise TypeError(
"ExtensionArray.fillna does not support filling with a dict. "
"Use Series.fillna instead."
)
if limit is not None:
raise ValueError("limit must be None")
value_left, value_right = self._validate_setitem_value(value)
left = self.left.fillna(value=value_left)
right = self.right.fillna(value=value_right)
return self._shallow_copy(left, right)
def astype(self, dtype, copy: bool = True):
"""
Cast to an ExtensionArray or NumPy array with dtype 'dtype'.
Parameters
----------View on GitHub (pinned to 71959b8cb9)
Solutions
- Call fillna on the Series: `s.fillna({...})`.
- If working on the array, fill with a single scalar Interval: `ia.fillna(pd.Interval(0,1))`.
- Map positions manually: build new left/right arrays and reconstruct the IntervalArray.
Example fix
// before
ia.fillna({0: pd.Interval(0, 1)})
// after
pd.Series(ia).fillna({0: pd.Interval(0, 1)}).values Defensive patterns
Strategy: validation
Validate before calling
def fillna_interval(ia, value):
import pandas as pd
if isinstance(value, dict):
return pd.Series(ia).fillna(value).values
return ia.fillna(value) Type guard
def is_dict_value(value) -> bool:
return isinstance(value, dict) Try / catch
try:
out = ia.fillna(value)
except TypeError as e:
if "does not support filling with a dict" in str(e):
out = pd.Series(ia).fillna(value).values
else:
raise Prevention
- Call fillna on the Series, not on .values, when using a dict.
- Pass a single scalar Interval to IntervalArray.fillna.
- Wrap interval columns as Series throughout the pipeline.
When it happens
Trigger: `ia.fillna({0: pd.Interval(0,1)})`, or calling `.fillna` on the `.values` of a Series with a dict.
Common situations: Calling `.values.fillna({...})` instead of the Series method; copy-pasting a Series fillna pattern onto the array.
Related errors
- limit must be None
- ExtensionArray.fillna does not support filling with a dict.
- cannot diff {type(arr).__name__} on axis={axis}
- {type(arr).__name__} has no 'diff' method. Convert to a suit
- cannot perform both aggregation and transformation operation
AI-assisted analysis of pandas-dev/pandas@71959b8cb9 (2026-08-07).
Data as JSON: /api/errors/a2937b138f76ab13.
Report an issue: GitHub.