apache/beam · error · WontImplementError

Numeric aggregation ( ) on a DataFrame containing…

Error message

Numeric aggregation ({func!r}) on a DataFrame containing non-numeric columns ({*nonnumeric_columns,!r} is not supported, unless `numeric_only=` is specified.
Use `numeric_only=True` to only aggregate over numeric columns.
Use `numeric_only=False` to aggregate over all columns. Note this is not recommended, as it could result in execution time errors.

What it means

Numeric aggregations (mean, sum, etc.) on a DeferredDataFrame that contains non-numeric columns require an explicit numeric_only argument. Pandas' silent column-dropping behavior is version-dependent and error-prone, so Beam raises WontImplementError unless the user opts in with numeric_only=True (aggregate numeric columns only) or numeric_only=False (attempt all columns, accepting possible runtime errors).

Solutions

  1. Pass numeric_only=True: ddf.mean(numeric_only=True).
  2. Select only numeric columns before aggregating: ddf[['a', 'b']].mean().
  3. Convert or drop non-numeric columns first (e.g. pd.to_numeric or del ddf['str_col']).
  4. Pass numeric_only=False only if you accept possible execution-time errors on non-numeric columns.

Example fix

// before
ddf.mean()

// after
ddf.mean(numeric_only=True)
# or
ddf[['col1', 'col2']].mean()
Defensive patterns

Strategy: validation

Validate before calling

numeric_cols = [c for c in ddf.columns if pd.api.types.is_numeric_dtype(schema_dtypes[c])]
if len(numeric_cols) < len(ddf.columns):
    result = ddf[numeric_cols].mean()  # or ddf.mean(numeric_only=True)

Type guard

def needs_numeric_only(columns, dtypes) -> bool:
    return any(not pd.api.types.is_numeric_dtype(t) for t in dtypes)

Try / catch

from apache_beam.dataframe import frame_base
try:
    out = ddf.mean()
except frame_base.WontImplementError:
    out = ddf.mean(numeric_only=True)

Prevention

When it happens

Trigger: Calling an aggregation like ddf.mean(), ddf.sum(), ddf.median() on a frame with non-numeric columns, without passing numeric_only, or with numeric_only=None.

Common situations: Frames built from CSV/JSON with a stray string column (e.g. an 'id' or 'notes' column) mixed into numeric data; pandas 2.x changed default numeric_only behavior, breaking migrated aggregation code.

Understand the failure class

Background: "missing required argument" and "the following required arguments were not provided": what required-argument errors mean and how to fix them — this error's family across 20 libraries.

Related errors


AI-assisted analysis of apache/beam@12126d8942 (2026-09-13). Data as JSON: /api/errors/7695380b3fab53bd. Report an issue: GitHub.

Appendix: source

Thrown at sdks/python/apache_beam/dataframe/frames.py:2935

      if isinstance(proxy, pd.DataFrame):
        projected = self[list(proxy.columns)]
      elif isinstance(proxy, pd.Series):
        projected = self[list(proxy.index)]
      else:
        projected = self

      nonnumeric_columns = [name for (name, dtype) in projected.dtypes.items()
                            if not
                            pd.core.dtypes.common.is_numeric_dtype(dtype)]

      if _is_numeric(func) and nonnumeric_columns:
        if 'numeric_only' in kwargs and kwargs['numeric_only'] is False:
          # User has opted in to execution with non-numeric columns, they
          # will accept runtime errors
          pass
        else:
          raise frame_base.WontImplementError(
              f"Numeric aggregation ({func!r}) on a DataFrame containing "
              f"non-numeric columns ({*nonnumeric_columns,!r} is not "
              "supported, unless `numeric_only=` is specified.\n"
              "Use `numeric_only=True` to only aggregate over numeric "
              "columns.\nUse `numeric_only=False` to aggregate over all "
              "columns. Note this is not recommended, as it could result in "
              "execution time errors.")

      for key in PROJECT_KWARGS:
        if key in kwargs:
          kwargs.pop(key)

      if not isinstance(func, dict):
        col_names = list(projected._expr.proxy().columns)
        func_by_col = {col: func for col in col_names}
      else:
        func_by_col = func
        col_names = list(func.keys())

View on GitHub (pinned to 12126d8942)