pathwaycom/pathway · error · ValueError

Table.groupby() received extra kwargs. You probably want to

Error message

Table.groupby() received extra kwargs.
You probably want to use Table.groupby(...).reduce(**kwargs) to compute output columns.

What it means

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.

Source

Thrown at python/pathway/internals/arg_handlers.py:38

        return inner

    return wrapper


def groupby_handler(
    self,
    *args,
    id=None,
    sort_by=None,
    _filter_out_results_of_forgetting=False,
    instance=None,
    _skip_errors=True,
    _is_window=False,
    **kwargs,
):
    if kwargs:
        raise ValueError(
            "Table.groupby() received extra kwargs.\n"
            + "You probably want to use Table.groupby(...).reduce(**kwargs) to compute output columns."
        )
    return (self, *args), {
        "id": id,
        "sort_by": sort_by,
        "_filter_out_results_of_forgetting": _filter_out_results_of_forgetting,
        "instance": instance,
        "_skip_errors": _skip_errors,
        "_is_window": _is_window,
    }


def windowby_handler(
    self, time_expr, *args, window, behavior=None, instance=None, **kwargs
):
    if args:
        raise ValueError(

View on GitHub (pinned to fa2f74a464)

Solutions

  1. Move output-column computations to reduce: t.groupby(t.key).reduce(s=pw.reducers.sum(t.value)).
  2. For counts use t.groupby(t.key).reduce(count=pw.reducers.count()).
  3. Keep only the documented kwargs (id, sort_by, instance) on groupby itself.

Example fix

# before
t2 = t.groupby(t.key, total=pw.reducers.sum(t.value))

# after
t2 = t.groupby(t.key).reduce(total=pw.reducers.sum(t.value))
Defensive patterns

Strategy: validation

Validate before calling

allowed = {"id", "sort_by", "instance", "_filter_out_results_of_forgetting", "_skip_errors", "_is_window"}
unknown = set(kwargs) - allowed
if unknown:
    raise TypeError(f"pass {unknown} to .reduce(), not .groupby()")

Prevention

When it happens

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

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

Related errors


AI-assisted analysis of pathwaycom/pathway@fa2f74a464 (2026-08-15). Data as JSON: /api/errors/edb6b28ae0305861. Report an issue: GitHub.