{"record":{"id":"612fe6aa6af0d5c1","repo":"pandas-dev/pandas","slug":"column-colname-is-backed-by-an-extension-array","errorCode":null,"errorMessage":"Column {colname} is backed by an extension array, which is not supported by the numba engine.","messagePattern":"Column (.+?) is backed by an extension array, which is not supported by the numba engine\\.","errorType":"exception","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"pandas/core/apply.py","lineNumber":984,"sourceCode":"    def generate_numba_apply_func(\n        func, nogil: bool = True, parallel: bool = False\n    ) -> Callable[[npt.NDArray, Index, Index], dict[int, Any]]:\n        pass\n\n    @abc.abstractmethod\n    def apply_with_numba(self):\n        pass\n\n    def validate_values_for_numba(self) -> None:\n        # Validate column dtypes all OK\n        for colname, dtype in self.obj.dtypes.items():\n            if not is_numeric_dtype(dtype):\n                raise ValueError(\n                    f\"Column {colname} must have a numeric dtype. \"\n                    f\"Found '{dtype}' instead\"\n                )\n            if is_extension_array_dtype(dtype):\n                raise ValueError(\n                    f\"Column {colname} is backed by an extension array, \"\n                    f\"which is not supported by the numba engine.\"\n                )\n\n    @abc.abstractmethod\n    def wrap_results_for_axis(\n        self, results: ResType, res_index: Index\n    ) -> DataFrame | Series:\n        pass\n\n    # ---------------------------------------------------------------\n\n    @property\n    def res_columns(self) -> Index:\n        return self.result_columns\n\n    @property\n    def columns(self) -> Index:","sourceCodeStart":966,"sourceCodeEnd":1002,"githubUrl":"https://github.com/pandas-dev/pandas/blob/3b7651241d4da534b3559b60ef128e1c34f54116/pandas/core/apply.py#L966-L1002","documentation":"Raised by `validate_values_for_numba` for a column whose dtype is an extension array (e.g. `Int64`, `Float64`, `boolean`, nullable types). Even if the dtype is numeric, numba operates on plain numpy buffers and cannot consume pandas ExtensionArrays, so pandas rejects them up front and names the offending column.","triggerScenarios":"`df.apply(func, engine='numba')` where any column is a nullable/extension dtype (`'Int64'`, `'Float64'`, `'boolean'`, etc.). The check `is_extension_array_dtype(dtype)` fires after the numeric check, so it only triggers for numeric extension dtypes.","commonSituations":"Frames produced by `convert_dtypes()` (which yields nullable Int64/Float64/boolean), or by reading data with `dtype='Int64'`; migrating to nullable dtypes without realizing numba does not support them.","solutions":["Cast extension columns to numpy equivalents: `df[col] = df[col].astype('int64')` (handle NA first).","Use `df.select_dtypes(exclude='extension')` or filter out EA columns before the numba call.","Fall back to the python engine for frames that must keep nullable dtypes."],"exampleFix":"// before\ndf.apply(func, engine='numba')  # df has Int64 (nullable) column\n// after\ndf.astype({'col': 'int64'}).apply(func, engine='numba')","handlingStrategy":"validation","validationCode":"def no_ea_numba_apply(df, func, **kw):\n    ea_cols = [c for c, d in df.dtypes.items() if pd.api.types.is_extension_array_dtype(d)]\n    if ea_cols:\n        raise ValueError(f'Extension-array columns block numba: {ea_cols}')\n    return df.apply(func, engine='numba', **kw)","typeGuard":"def frame_has_no_extension_arrays(df) -> bool:\n    return not any(pd.api.types.is_extension_array_dtype(d) for d in df.dtypes)","tryCatchPattern":"try:\n    out = df.apply(func, engine='numba')\nexcept ValueError as e:\n    if 'extension array' in str(e):\n        cast = df.copy()\n        for c in cast.columns:\n            if pd.api.types.is_extension_array_dtype(cast[c]):\n                cast[c] = cast[c].astype(cast[c].dtype._subtype if hasattr(cast[c].dtype, '_subtype') else 'float64')\n        out = cast.apply(func, engine='numba')\n    else:\n        raise","preventionTips":["Avoid convert_dtypes() before numba paths.","Cast nullable Int64/Float64 to numpy int64/float64 after handling NaNs.","Document which pipelines require plain numpy dtypes."],"tags":["pandas","apply","numba","extension-array","dtype","valueerror"],"backgroundTag":null,"analyzedSha":"3b7651241d4da534b3559b60ef128e1c34f54116","analyzedAt":"2026-08-11T22:10:44.015Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}