apache/beam · error · WontImplementError

quantile(axis=columns) with multiple q values is not…

Error message

quantile(axis=columns) with multiple q values is not supported because it transposes the input DataFrame. Note computing an individual quantile across columns (e.g. df.quantile(q={q[0]!r}, axis={axis!r}) is supported.

What it means

Beam's DataFrame.quantile with axis='columns' throws WontImplementError when a list of q values is passed because pandas would transpose the DataFrame, producing a non-static schema that Beam cannot represent. A single scalar q across columns is supported.

Solutions

  1. Issue one quantile call per q value with scalar q and axis='columns', then combine results.
  2. Switch to axis=0 (row-wise across columns of the frame), which supports lists of q.
  3. Compute quantiles locally with pandas if the dataset fits in memory.

Example fix

// before
qs = df.quantile(q=[0.25, 0.5, 0.75], axis='columns')
// after
qs = {q: df.quantile(q=q, axis='columns') for q in (0.25, 0.5, 0.75)}
Defensive patterns

Strategy: validation

Validate before calling

def check_quantile_args(q, axis):
    if axis in (1, 'columns') and isinstance(q, list):
        raise ValueError('quantile(axis=columns) requires a scalar q in Beam')

Type guard

def quantile_supported(q, axis) -> bool:
    return not (axis in (1, 'columns') and isinstance(q, list))

Try / catch

from apache_beam.dataframe import frame_base
try:
    res = df.quantile(q=[0.25, 0.75], axis='columns')
except frame_base.WontImplementError:
    res = {q: df.quantile(q=q, axis='columns') for q in (0.25, 0.75)}

Prevention

When it happens

Trigger: Calling df.quantile(q=[0.25, 0.5, 0.75], axis='columns') (or axis=1) on a DeferredDataFrame with a list of quantiles.

Common situations: Computing several per-row quantiles at once, as commonly done in pandas; users reusing list-of-q patterns across axis switches.

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 apache/beam@12126d8942 (2026-09-13). Data as JSON: /api/errors/cfaadaeac1a440a0. Report an issue: GitHub.

Appendix: source

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

            [self._expr],
            preserves_partition_by=partitionings.Arbitrary(),
            requires_partition_by=partitionings.Arbitrary())
    return result

  @frame_base.with_docs_from(pd.DataFrame)
  @frame_base.args_to_kwargs(pd.DataFrame)
  @frame_base.populate_defaults(pd.DataFrame)
  def quantile(self, q, axis, **kwargs):
    """``quantile(axis="index")`` is not parallelizable. See
    `Issue 20933 <https://github.com/apache/beam/issues/20933>`_ tracking
    the possible addition of an approximate, parallelizable implementation of
    quantile.

    When using quantile with ``axis="columns"`` only a single ``q`` value can be
    specified."""
    if axis in (1, 'columns'):
      if isinstance(q, list):
        raise frame_base.WontImplementError(
            "quantile(axis=columns) with multiple q values is not supported "
            "because it transposes the input DataFrame. Note computing "
            "an individual quantile across columns (e.g. "
            f"df.quantile(q={q[0]!r}, axis={axis!r}) is supported.",
            reason="non-deferred-columns")
      else:
        requires = partitionings.Arbitrary()
    else: # axis='index'
      # TODO(https://github.com/apache/beam/issues/20933): Provide an option
      # for approximate distributed quantiles
      requires = partitionings.Singleton(reason=(
          "Computing quantiles across index cannot currently be parallelized. "
          "See https://github.com/apache/beam/issues/20933 tracking the "
          "possible addition of an approximate, parallelizable implementation "
          "of quantile."
      ))

    return frame_base.DeferredFrame.wrap(

View on GitHub (pinned to 12126d8942)