{"record":{"id":"c6de87fe26453eea","repo":"pathwaycom/pathway","slug":"wrong-output-universe-no-argument-of-name-arg","errorCode":null,"errorMessage":"wrong output universe. No argument of name: {arg}","messagePattern":"wrong output universe\\. No argument of name: (.+?)","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"python/pathway/stdlib/utils/pandas_transformer.py","lineNumber":46,"sourceCode":"        reduced = tupled_cols.reduce(\n            **{f\"_{idx}\": pw.reducers.sorted_tuple(tupled_cols.all_cols)}\n        )\n        result.append(reduced)\n\n    def _add_tables(first: pw.Table, *tables: pw.Table) -> pw.Table:\n        for table in tables:\n            first += table.with_universe_of(first)\n        return first\n\n    return _add_tables(*result)\n\n\ndef _argument_index(func_spec: FunctionSpec, arg: str | int | None) -> int | None:\n    if isinstance(arg, str):\n        try:\n            return func_spec.arg_names.index(arg)\n        except ValueError:\n            raise ValueError(f\"wrong output universe. No argument of name: {arg}\")\n    elif isinstance(arg, int):\n        if arg < 0 or arg >= len(func_spec.arg_names):\n            raise ValueError(\"wrong output universe. Index out of range\")\n    return arg\n\n\ndef _pandas_transformer(\n    *inputs: pw.Table,\n    func_spec: FunctionSpec,\n    output_schema: type[schema.Schema],\n    output_universe: str | int | None,\n) -> pw.Table:\n    output_universe_arg_index = _argument_index(func_spec, output_universe)\n    func = func_spec.func\n\n    def process_pandas_output(\n        result: pd.DataFrame | pd.Series, pandas_input: list[pd.DataFrame] = []\n    ):","sourceCodeStart":28,"sourceCodeEnd":64,"githubUrl":"https://github.com/pathwaycom/pathway/blob/fa2f74a4649b7c5908690cf60137263d8d80de5f/python/pathway/stdlib/utils/pandas_transformer.py#L28-L64","documentation":"In the pandas UDF adapter, output_universe names which function argument's table defines the output universe: its index becomes the resulting table's universe. When output_universe is a string, _argument_index looks it up in func_spec.arg_names; if the wrapped function has no parameter with that name, the lookup ValueError is re-raised with this message.","triggerScenarios":"pw.pandas_transformer-style decorator with output_universe='right' where the wrapped UDF's parameters are (left_df, other_df); a typo in the argument name; renaming the UDF parameters without updating output_universe.","commonSituations":"Adapting example code where argument names differ from your function's signature; IDE auto-renaming UDF parameters; switching between name-based and index-based output_universe.","solutions":["Set output_universe to the exact parameter name of the UDF that should define the output index","Or switch to the positional form output_universe=<index of that argument>","Print inspect.signature(func) / the decorator's function spec to confirm the recognized names"],"exampleFix":"# before\n@pw.pandas_transformer(output_universe='right')\ndef f(left: pd.DataFrame, other: pd.DataFrame) -> pd.DataFrame: ...\n\n# after\n@pw.pandas_transformer(output_universe='other')\ndef f(left: pd.DataFrame, other: pd.DataFrame) -> pd.DataFrame: ...","handlingStrategy":"validation","validationCode":"import inspect\nnames = list(inspect.signature(your_udf).parameters)\nassert output_universe in names, f'output_universe {output_universe!r} not in UDF args {names}'","typeGuard":"def output_universe_name_is_valid(func, name: str) -> bool:\n    import inspect\n    return name in inspect.signature(func).parameters","tryCatchPattern":null,"preventionTips":["Prefer parameter-name output_universe over positional index","When renaming UDF parameters, update the decorator arguments in the same change","Assert the name/index against inspect.signature in a smoke test"],"tags":["pathway","pandas","udf","argument-validation"],"backgroundTag":null,"analyzedSha":"fa2f74a4649b7c5908690cf60137263d8d80de5f","analyzedAt":"2026-08-15T01:48:17.006Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}