pola-rs/polars · error · NotImplementedError

TODO: map target not yet supported.

Error message

TODO: {map_target!r} map target not yet supported.

What it means

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... ?').

Solutions

  1. Avoid DataFrame.map; restructure as per-row/per-expression logic on columns (map_elements on Expr, or vectorized expressions).
  2. Use native polars expressions instead of a Python UDF so no bytecode parsing is needed.
  3. Upgrade polars and check if support for this target was added; otherwise file an upstream issue.

Example fix

// before
df.map(lambda df: df * 2)
// after
df.with_columns(pl.all() * 2)
Defensive patterns

Strategy: validation

Validate before calling

if not isinstance(map_target, (pl.Expr, pl.Series)):
    raise TypeError('expected an Expr or Series map target')

Type guard

def is_supported_target(t) -> bool:
    import polars as pl
    return isinstance(t, (pl.Expr, pl.Series))

Try / catch

try:
    df.map(fn)
except NotImplementedError as e:
    if 'map target not yet supported' in str(e):
        result = df.with_columns(pl.all() * 2)  # native rewrite

Prevention

When it happens

Trigger: 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.

Common situations: 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.

Understand the failure class

Background: UnsupportedOperationException and "is not supported" errors: when a library deliberately refuses a call — this error's family across 30 libraries.

Related errors


AI-assisted analysis of pola-rs/polars@fe841f959e (2026-09-18). Data as JSON: /api/errors/442f06cab8971506. Report an issue: GitHub.

Appendix: source

Thrown at py-polars/src/polars/_utils/udfs.py:779

                        )
                        if (
                            inst.opname in OpNames.UNARY
                            or OpNames.SYNTHETIC.get(inst.opname) == 1
                        )
                        else StackValue(
                            operator=self.op(inst),
                            operator_arity=2,
                            left_operand=stack.pop(-2),  # type: ignore[arg-type]
                            right_operand=stack.pop(-1),  # type: ignore[arg-type]
                            from_module=getattr(inst, "_from_module", None),
                        )
                    )
                )
            return stack[0]

        # TODO: dataframe.map... ?
        msg = f"TODO: {map_target!r} map target not yet supported."
        raise NotImplementedError(msg)


class RewrittenInstructions:
    """
    Standalone class that applies Instruction rewrite/filtering rules.

    This significantly simplifies subsequent parsing by injecting
    synthetic POLARS_EXPRESSION ops into the Instruction stream for
    easy identification/translation, and separates the parsing logic
    from the identification of expression translation opportunities.
    """

    _ignored_ops = frozenset(
        [
            "COPY",
            "COPY_FREE_VARS",
            "NOT_TAKEN",
            "POP_TOP",

View on GitHub (pinned to fe841f959e)