{"record":{"id":"cfaadaeac1a440a0","repo":"apache/beam","slug":"quantile-axis-columns-with-multiple-q-values-is-not","errorCode":null,"errorMessage":"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.","messagePattern":"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=(.+?), axis=(.+?)\\) is supported\\.","errorType":"exception","errorClass":"WontImplementError","httpStatus":null,"severity":"error","filePath":"sdks/python/apache_beam/dataframe/frames.py","lineNumber":3643,"sourceCode":"            [self._expr],\n            preserves_partition_by=partitionings.Arbitrary(),\n            requires_partition_by=partitionings.Arbitrary())\n    return result\n\n  @frame_base.with_docs_from(pd.DataFrame)\n  @frame_base.args_to_kwargs(pd.DataFrame)\n  @frame_base.populate_defaults(pd.DataFrame)\n  def quantile(self, q, axis, **kwargs):\n    \"\"\"``quantile(axis=\"index\")`` is not parallelizable. See\n    `Issue 20933 <https://github.com/apache/beam/issues/20933>`_ tracking\n    the possible addition of an approximate, parallelizable implementation of\n    quantile.\n\n    When using quantile with ``axis=\"columns\"`` only a single ``q`` value can be\n    specified.\"\"\"\n    if axis in (1, 'columns'):\n      if isinstance(q, list):\n        raise frame_base.WontImplementError(\n            \"quantile(axis=columns) with multiple q values is not supported \"\n            \"because it transposes the input DataFrame. Note computing \"\n            \"an individual quantile across columns (e.g. \"\n            f\"df.quantile(q={q[0]!r}, axis={axis!r}) is supported.\",\n            reason=\"non-deferred-columns\")\n      else:\n        requires = partitionings.Arbitrary()\n    else: # axis='index'\n      # TODO(https://github.com/apache/beam/issues/20933): Provide an option\n      # for approximate distributed quantiles\n      requires = partitionings.Singleton(reason=(\n          \"Computing quantiles across index cannot currently be parallelized. \"\n          \"See https://github.com/apache/beam/issues/20933 tracking the \"\n          \"possible addition of an approximate, parallelizable implementation \"\n          \"of quantile.\"\n      ))\n\n    return frame_base.DeferredFrame.wrap(","sourceCodeStart":3625,"sourceCodeEnd":3661,"githubUrl":"https://github.com/apache/beam/blob/12126d8942aaf848030c478b4c6a28c6af861c66/sdks/python/apache_beam/dataframe/frames.py#L3625-L3661","documentation":"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.","triggerScenarios":"Calling df.quantile(q=[0.25, 0.5, 0.75], axis='columns') (or axis=1) on a DeferredDataFrame with a list of quantiles.","commonSituations":"Computing several per-row quantiles at once, as commonly done in pandas; users reusing list-of-q patterns across axis switches.","solutions":["Issue one quantile call per q value with scalar q and axis='columns', then combine results.","Switch to axis=0 (row-wise across columns of the frame), which supports lists of q.","Compute quantiles locally with pandas if the dataset fits in memory."],"exampleFix":"// before\nqs = df.quantile(q=[0.25, 0.5, 0.75], axis='columns')\n// after\nqs = {q: df.quantile(q=q, axis='columns') for q in (0.25, 0.5, 0.75)}","handlingStrategy":"validation","validationCode":"def check_quantile_args(q, axis):\n    if axis in (1, 'columns') and isinstance(q, list):\n        raise ValueError('quantile(axis=columns) requires a scalar q in Beam')","typeGuard":"def quantile_supported(q, axis) -> bool:\n    return not (axis in (1, 'columns') and isinstance(q, list))","tryCatchPattern":"from apache_beam.dataframe import frame_base\ntry:\n    res = df.quantile(q=[0.25, 0.75], axis='columns')\nexcept frame_base.WontImplementError:\n    res = {q: df.quantile(q=q, axis='columns') for q in (0.25, 0.75)}","preventionTips":["Use scalar q whenever quantiling across columns in Beam.","Restrict list-of-q usage to axis=0 computations.","Review the Beam DataFrame support matrix before porting pandas snippets."],"tags":["pandas","apache-beam","dataframe","unsupported-operation"],"backgroundTag":"unsupported-operation","analyzedSha":"12126d8942aaf848030c478b4c6a28c6af861c66","analyzedAt":"2026-09-13T01:50:10.254Z","contentChangedAt":"2026-09-13T01:50:10.254Z","schemaVersion":2},"datasetVersion":"2026-09-20T03:17:13.778Z"}