{"record":{"id":"a2937b138f76ab13","repo":"pandas-dev/pandas","slug":"extensionarray-fillna-does-not-support-filling-wit-a2937b","errorCode":null,"errorMessage":"ExtensionArray.fillna does not support filling with a dict. Use Series.fillna instead.","messagePattern":"ExtensionArray\\.fillna does not support filling with a dict\\. Use Series\\.fillna instead\\.","errorType":"validation","errorClass":"TypeError","httpStatus":null,"severity":"error","filePath":"pandas/core/arrays/interval.py","lineNumber":899,"sourceCode":"            values for each index. The value should not be a list. The\n            value(s) passed should be either Interval objects or NA/NaN.\n        limit : int, default None\n            (Not implemented yet for IntervalArray)\n            The maximum number of entries where NA values will be filled.\n        copy : bool, default True\n            Whether to make a copy of the data before filling. If False, then\n            the original should be modified and no new memory should be allocated.\n            For ExtensionArray subclasses that cannot do this, it is at the\n            author's discretion whether to ignore \"copy=False\" or to raise.\n\n        Returns\n        -------\n        filled : IntervalArray with NA/NaN filled\n        \"\"\"\n        if copy is False:\n            raise NotImplementedError\n        if isinstance(value, dict):\n            raise TypeError(\n                \"ExtensionArray.fillna does not support filling with a dict. \"\n                \"Use Series.fillna instead.\"\n            )\n        if limit is not None:\n            raise ValueError(\"limit must be None\")\n\n        value_left, value_right = self._validate_setitem_value(value)\n\n        left = self.left.fillna(value=value_left)\n        right = self.right.fillna(value=value_right)\n        return self._shallow_copy(left, right)\n\n    def astype(self, dtype, copy: bool = True):\n        \"\"\"\n        Cast to an ExtensionArray or NumPy array with dtype 'dtype'.\n\n        Parameters\n        ----------","sourceCodeStart":881,"sourceCodeEnd":917,"githubUrl":"https://github.com/pandas-dev/pandas/blob/3b7651241d4da534b3559b60ef128e1c34f54116/pandas/core/arrays/interval.py#L881-L917","documentation":"Raised by `IntervalArray.fillna` when `value` is a dict. The ExtensionArray.fillna contract does not support dict-based filling (which maps per-index-label, requiring index information the array does not own); the user is redirected to Series.fillna which has an index.","triggerScenarios":"`interval_array.fillna({0: pd.Interval(0,1)})`; calling `.fillna` on `df['col'].array` with a dict.","commonSituations":"User copies a dict-based fillna pattern from a Series workflow onto the underlying array; extracting `.array` to avoid Series overhead then trying dict fill.","solutions":["Use Series.fillna with the dict: `s.fillna({0: ...})`.","If you must work on the array, convert dict keys to positions and assign per-position with `__setitem__`.","For a single fill value, pass a scalar Interval to `array.fillna`."],"exampleFix":"# before\ndf['bins'].array.fillna({0: pd.Interval(0,1)})\n\n# after\ndf['bins'].fillna({0: pd.Interval(0,1)})\n# or scalar\narr.fillna(pd.Interval(0,1))","handlingStrategy":"type-guard","validationCode":"import pandas as pd\nfrom collections.abc import Mapping\n\ndef fillna_interval_array(arr, value):\n    if isinstance(value, Mapping):\n        raise TypeError('use Series.fillna for dict; array has no index')\n    return arr.fillna(value)","typeGuard":"from collections.abc import Mapping\n\ndef is_dict_fill(value) -> bool:\n    return isinstance(value, Mapping)","tryCatchPattern":"try:\n    arr.fillna(value)\nexcept TypeError as e:\n    if 'does not support filling with a dict' in str(e):\n        series.fillna(value)  # fall back to Series-level fill\n    else:\n        raise","preventionTips":["Use Series.fillna (not array.fillna) when filling with a dict.","For single-value fill on the array, pass a scalar Interval.","Keep dict-based fill logic at the Series/DataFrame layer."],"tags":["interval","fillna","dict-fill","type-error","extension-array"],"backgroundTag":null,"analyzedSha":"3b7651241d4da534b3559b60ef128e1c34f54116","analyzedAt":"2026-08-11T22:10:44.015Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}