{"record":{"id":"442f06cab8971506","repo":"pola-rs/polars","slug":"todo-map-target-r-map-target-not-yet-supported","errorCode":null,"errorMessage":"TODO: {map_target!r} map target not yet supported.","messagePattern":"TODO: (.+?) map target not yet supported\\.","errorType":"exception","errorClass":"NotImplementedError","httpStatus":null,"severity":"error","filePath":"py-polars/src/polars/_utils/udfs.py","lineNumber":779,"sourceCode":"                        )\n                        if (\n                            inst.opname in OpNames.UNARY\n                            or OpNames.SYNTHETIC.get(inst.opname) == 1\n                        )\n                        else StackValue(\n                            operator=self.op(inst),\n                            operator_arity=2,\n                            left_operand=stack.pop(-2),  # type: ignore[arg-type]\n                            right_operand=stack.pop(-1),  # type: ignore[arg-type]\n                            from_module=getattr(inst, \"_from_module\", None),\n                        )\n                    )\n                )\n            return stack[0]\n\n        # TODO: dataframe.map... ?\n        msg = f\"TODO: {map_target!r} map target not yet supported.\"\n        raise NotImplementedError(msg)\n\n\nclass RewrittenInstructions:\n    \"\"\"\n    Standalone class that applies Instruction rewrite/filtering rules.\n\n    This significantly simplifies subsequent parsing by injecting\n    synthetic POLARS_EXPRESSION ops into the Instruction stream for\n    easy identification/translation, and separates the parsing logic\n    from the identification of expression translation opportunities.\n    \"\"\"\n\n    _ignored_ops = frozenset(\n        [\n            \"COPY\",\n            \"COPY_FREE_VARS\",\n            \"NOT_TAKEN\",\n            \"POP_TOP\",","sourceCodeStart":761,"sourceCodeEnd":797,"githubUrl":"https://github.com/pola-rs/polars/blob/fe841f959ef4d2ceefc05a310d33ed7b1ab24e5e/py-polars/src/polars/_utils/udfs.py#L761-L797","documentation":"The UDF parser supports rewriting map targets that are Expr or Series; anything else (e.g. DataFrame.map) has no translation and raises NotImplementedError with the repr of the target. It is an explicit not-yet-supported marker (the source comment says 'TODO: dataframe.map... ?').","triggerScenarios":"Calling warn/parsing machinery with a map_target that is a DataFrame (e.g. df.map(fn)) or other unsupported object, so _to_intermediate_stack falls through to the TODO branch during parser construction.","commonSituations":"Using DataFrame.map with a row-wise function and expecting the efficiency warning/rewrite machinery to analyze it; passing an unsupported callable type to map-family APIs.","solutions":["Avoid DataFrame.map; restructure as per-row/per-expression logic on columns (map_elements on Expr, or vectorized expressions).","Use native polars expressions instead of a Python UDF so no bytecode parsing is needed.","Upgrade polars and check if support for this target was added; otherwise file an upstream issue."],"exampleFix":"// before\ndf.map(lambda df: df * 2)\n// after\ndf.with_columns(pl.all() * 2)","handlingStrategy":"validation","validationCode":"if not isinstance(map_target, (pl.Expr, pl.Series)):\n    raise TypeError('expected an Expr or Series map target')","typeGuard":"def is_supported_target(t) -> bool:\n    import polars as pl\n    return isinstance(t, (pl.Expr, pl.Series))","tryCatchPattern":"try:\n    df.map(fn)\nexcept NotImplementedError as e:\n    if 'map target not yet supported' in str(e):\n        result = df.with_columns(pl.all() * 2)  # native rewrite","preventionTips":["Avoid DataFrame.map with Python functions","Use column-wise expressions instead of frame-level maps","Check polars changelog for frame-map support"],"tags":["python","polars","udf","dataframe-map"],"backgroundTag":"unsupported-operation","analyzedSha":"fe841f959ef4d2ceefc05a310d33ed7b1ab24e5e","analyzedAt":"2026-09-18T22:14:11.667Z","contentChangedAt":"2026-09-18T22:14:11.667Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}