{"record":{"id":"1ef14c6dd2a42934","repo":"pandas-dev/pandas","slug":"extensionarray-fillna-does-not-support-filling-wit","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":"exception","errorClass":"TypeError","httpStatus":null,"severity":"error","filePath":"pandas/core/arrays/arrow/array.py","lineNumber":1719,"sourceCode":"            NA values.\n        api.extensions.ExtensionArray.isna : A 1-D array indicating if\n            each value is missing.\n\n        Examples\n        --------\n        >>> arr = pd.array(\n        ...     [np.nan, np.nan, 2, 3, np.nan, np.nan], dtype=\"int64[pyarrow]\"\n        ... )\n        >>> arr.fillna(0)\n        <ArrowExtensionArray>\n        [0, 0, 2, 3, 0, 0]\n        Length: 6, dtype: int64[pyarrow]\n        \"\"\"\n        if not self._hasna:\n            return self.copy()\n\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\n        if limit is not None:\n            return super().fillna(value=value, limit=limit, copy=copy)\n\n        if isinstance(value, (np.ndarray, ExtensionArray)):\n            # Similar to check_value_size, but we do not mask here since we may\n            #  end up passing it to the super() method.\n            if len(value) != len(self):\n                raise ValueError(\n                    f\"Length of 'value' does not match. Got ({len(value)}) \"\n                    f\" expected {len(self)}\"\n                )\n\n        try:\n            fill_value = self._box_pa(value, pa_type=self._pa_array.type)","sourceCodeStart":1701,"sourceCodeEnd":1737,"githubUrl":"https://github.com/pandas-dev/pandas/blob/3b7651241d4da534b3559b60ef128e1c34f54116/pandas/core/arrays/arrow/array.py#L1701-L1737","documentation":"Raised by ArrowExtensionArray.fillna when `value` is a dict. The extension-array-level fillna only supports scalar and array-like values; dict-based per-index filling is a Series/DataFrame concern because it requires label alignment. Users are redirected to Series.fillna.","triggerScenarios":"arr.fillna({0: 10, 1: 20}) on an ArrowExtensionArray; calling .fillna on the underlying array of a Series with a dict (rare, since Series.fillna usually intercepts); custom code that pulls the .array property and calls fillna(dict).","commonSituations":"Users who learned the dict syntax from Series.fillna and try it on the raw extension array; tutorials showing dict-based filling applied at the wrong layer; converting code from object dtype to pyarrow without adjusting the fill call.","solutions":["Use Series.fillna(dict) or DataFrame.fillna(dict) instead of operating on the raw array.","If you must use the array, expand the dict to an array-like of the same length aligned to positions.","Build a position-aligned fill array from the dict: np.array([d.get(i, default) for i in range(len(arr))])."],"exampleFix":"# before\narr = pd.array([1, None, 3], dtype=\"int64[pyarrow]\")\narr.fillna({1: 99})  # raises TypeError\n\n# after\npd.Series(arr).fillna({1: 99}).array","handlingStrategy":"type-guard","validationCode":"def safe_fillna(arr, value, **kw):\n    if isinstance(value, dict):\n        raise TypeError('Use Series.fillna(dict) instead of array.fillna(dict)')\n    return arr.fillna(value, **kw)","typeGuard":"def is_dict_value(v) -> bool:\n    return isinstance(v, dict)","tryCatchPattern":null,"preventionTips":["Call Series.fillna(dict) instead of operating on the raw extension array.","Expand dicts to position-aligned arrays before array-level fillna.","Keep dict-based filling at the Series/DataFrame layer."],"tags":["fillna","dict","api-misuse","validation"],"backgroundTag":null,"analyzedSha":"3b7651241d4da534b3559b60ef128e1c34f54116","analyzedAt":"2026-08-11T22:10:44.015Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}