{"record":{"id":"edb6b28ae0305861","repo":"pathwaycom/pathway","slug":"table-groupby-received-extra-kwargs-you-probabl","errorCode":null,"errorMessage":"Table.groupby() received extra kwargs.\nYou probably want to use Table.groupby(...).reduce(**kwargs) to compute output columns.","messagePattern":"Table\\.groupby\\(\\) received extra kwargs\\.\nYou probably want to use Table\\.groupby\\(\\.\\.\\.\\)\\.reduce\\(\\*\\*kwargs\\) to compute output columns\\.","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"python/pathway/internals/arg_handlers.py","lineNumber":38,"sourceCode":"\n        return inner\n\n    return wrapper\n\n\ndef groupby_handler(\n    self,\n    *args,\n    id=None,\n    sort_by=None,\n    _filter_out_results_of_forgetting=False,\n    instance=None,\n    _skip_errors=True,\n    _is_window=False,\n    **kwargs,\n):\n    if kwargs:\n        raise ValueError(\n            \"Table.groupby() received extra kwargs.\\n\"\n            + \"You probably want to use Table.groupby(...).reduce(**kwargs) to compute output columns.\"\n        )\n    return (self, *args), {\n        \"id\": id,\n        \"sort_by\": sort_by,\n        \"_filter_out_results_of_forgetting\": _filter_out_results_of_forgetting,\n        \"instance\": instance,\n        \"_skip_errors\": _skip_errors,\n        \"_is_window\": _is_window,\n    }\n\n\ndef windowby_handler(\n    self, time_expr, *args, window, behavior=None, instance=None, **kwargs\n):\n    if args:\n        raise ValueError(","sourceCodeStart":20,"sourceCodeEnd":56,"githubUrl":"https://github.com/pathwaycom/pathway/blob/fa2f74a4649b7c5908690cf60137263d8d80de5f/python/pathway/internals/arg_handlers.py#L20-L56","documentation":"Table.groupby() accepts only column references as positional arguments plus a fixed set of keyword options (id, sort_by, instance, ...). It is not the place to compute output columns; aggregation outputs belong to the chained .reduce(**kwargs) call. If any unrecognized keyword arguments reach groupby, this ValueError is raised with that hint. This mirrors pandas' groupby/agg split, which developers coming from pandas often collapse into one call.","triggerScenarios":"pw.Table.groupby(t.key, value=pw.reducers.sum(t.value)) or t.groupby(t.key).count_column='v'; any kwarg other than id/sort_by/instance/_filter_out_results_of_forgetting/_skip_errors/_is_window.","commonSituations":"Translating pandas code df.groupby('key').agg(sum=('v','sum')) into a single Pathway call; writing t.groupby(t.key, sort_by=t.time) is fine but adding aggregation kwargs is not; muscle memory from other dataframe APIs.","solutions":["Move output-column computations to reduce: t.groupby(t.key).reduce(s=pw.reducers.sum(t.value)).","For counts use t.groupby(t.key).reduce(count=pw.reducers.count()).","Keep only the documented kwargs (id, sort_by, instance) on groupby itself."],"exampleFix":"# before\nt2 = t.groupby(t.key, total=pw.reducers.sum(t.value))\n\n# after\nt2 = t.groupby(t.key).reduce(total=pw.reducers.sum(t.value))","handlingStrategy":"validation","validationCode":"allowed = {\"id\", \"sort_by\", \"instance\", \"_filter_out_results_of_forgetting\", \"_skip_errors\", \"_is_window\"}\nunknown = set(kwargs) - allowed\nif unknown:\n    raise TypeError(f\"pass {unknown} to .reduce(), not .groupby()\")","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Internalize the two-step shape: groupby(...) selects keys, reduce(...) computes columns.","When translating pandas agg code, map each output spec to a kwarg of reduce.","Enable editor signature help / type checking so unexpected kwargs on groupby are flagged."],"tags":["groupby","reduce","api-misuse","pandas"],"backgroundTag":null,"analyzedSha":"fa2f74a4649b7c5908690cf60137263d8d80de5f","analyzedAt":"2026-08-15T01:48:17.006Z","schemaVersion":2},"datasetVersion":"2026-08-15T17:31:12.345Z"}