{"record":{"id":"641b60283605b439","repo":"apache/beam","slug":"passing-a-deferred-series-to-round-is-not-supported-please","errorCode":null,"errorMessage":"Passing a deferred series to round() is not supported, please use a concrete pd.Series instance or a dictionary","messagePattern":"Passing a deferred series to round\\(\\) is not supported, please use a concrete pd\\.Series instance or a dictionary","errorType":"exception","errorClass":"NotImplementedError","httpStatus":null,"severity":"error","filePath":"sdks/python/apache_beam/dataframe/frames.py","lineNumber":3736,"sourceCode":"        expressions.ComputedExpression(\n            'rename',\n            lambda df: df.rename(**kwargs),\n            [self._expr],\n            proxy=proxy,\n            preserves_partition_by=preserves_partition_by,\n            requires_partition_by=requires_partition_by))\n\n  rename_axis = frame_base._elementwise_method('rename_axis', base=pd.DataFrame)\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 round(self, decimals, *args, **kwargs):\n\n    if isinstance(decimals, frame_base.DeferredFrame):\n      # Disallow passing a deferred Series in, our current partitioning model\n      # prevents us from using it correctly.\n      raise NotImplementedError(\"Passing a deferred series to round() is not \"\n                                \"supported, please use a concrete pd.Series \"\n                                \"instance or a dictionary\")\n\n    return frame_base.DeferredFrame.wrap(\n        expressions.ComputedExpression(\n            'round',\n            lambda df: df.round(decimals, *args, **kwargs),\n            [self._expr],\n            requires_partition_by=partitionings.Arbitrary(),\n            preserves_partition_by=partitionings.Index()\n        )\n    )\n\n  select_dtypes = frame_base._elementwise_method('select_dtypes',\n                                                 base=pd.DataFrame)\n\n  @frame_base.with_docs_from(pd.DataFrame)\n  @frame_base.args_to_kwargs(pd.DataFrame)","sourceCodeStart":3718,"sourceCodeEnd":3754,"githubUrl":"https://github.com/apache/beam/blob/12126d8942aaf848030c478b4c6a28c6af861c66/sdks/python/apache_beam/dataframe/frames.py#L3718-L3754","documentation":"DeferredFrame.round() rejects a deferred (Beam) Series as the decimals argument. Beam's partitioning model cannot align a distributed rounding spec with the frame, so it requires a concrete pandas Series or a plain dict mapping column names to decimal places.","triggerScenarios":"Calling df.beam.round(decimals_series.beam) where decimals is a DeferredSeries instead of a pd.Series or dict","commonSituations":"Keeping per-column precision specs as a Beam Series and passing it straight into round()","solutions":["Pass a plain dict like {'col_a': 2, 'col_b': 0}","Materialize the decimals series with .to_pandas() before passing it","Use pandas series computed locally for the rounding spec"],"exampleFix":"// before\ndf.beam.round(spec.beam)\n// after\ndf.beam.round({'price': 2, 'qty': 0})  # or spec.beam.to_pandas()","handlingStrategy":"type-guard","validationCode":"if isinstance(decimals, frame_base.DeferredFrame):\n    decimals = decimals.to_pandas()","typeGuard":"def is_valid_decimals(d):\n    return isinstance(d, (int, dict, pd.Series)) and not isinstance(d, frame_base.DeferredFrame)","tryCatchPattern":"try:\n    out = dframe.round({'a': 2})\nexcept NotImplementedError:\n    out = dframe.round(decimals.to_pandas())","preventionTips":["Express per-column rounding as dicts, not Series","Never pass DeferredFrame objects as scalar arguments to Beam frame methods","Materialize small metadata Series with to_pandas() at pipeline construction time"],"tags":["python","apache-beam","dataframe","round","type-mismatch"],"backgroundTag":"incompatible-source-type","analyzedSha":"12126d8942aaf848030c478b4c6a28c6af861c66","analyzedAt":"2026-09-13T01:50:10.254Z","contentChangedAt":"2026-09-13T01:50:10.254Z","schemaVersion":2},"datasetVersion":"2026-09-14T16:17:12.679Z"}