{"record":{"id":"87dae060b90700f2","repo":"apache/beam","slug":"fillna-method-method-r-axis-axis-r-is-not-supported-because","errorCode":null,"errorMessage":"fillna(method={method!r}, axis={axis!r}) is not supported because it is order-sensitive. Only fillna(method=None) is supported with axis={axis!r}.","messagePattern":"fillna\\(method=(.+?), axis=(.+?)\\) is not supported because it is order-sensitive\\. Only fillna\\(method=None\\) is supported with axis=(.+?)\\.","errorType":"exception","errorClass":"WontImplementError","httpStatus":null,"severity":"error","filePath":"sdks/python/apache_beam/dataframe/frames.py","lineNumber":278,"sourceCode":"    return frame_base.DeferredFrame.wrap(\n        expressions.ComputedExpression(\n            'swaplevel', lambda df: df.swaplevel(**kwargs), [self._expr],\n            requires_partition_by=partitionings.Arbitrary(),\n            preserves_partition_by=partitionings.Arbitrary()))\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  @frame_base.maybe_inplace\n  def fillna(self, value, method, axis, limit, **kwargs):\n    \"\"\"When ``axis=\"index\"``, both ``method`` and ``limit`` must be ``None``.\n    otherwise this operation is order-sensitive.\"\"\"\n    # Default value is None, but is overriden with index.\n    axis = axis or 'index'\n\n    if axis in (0, 'index'):\n      if method is not None:\n        raise frame_base.WontImplementError(\n            f\"fillna(method={method!r}, axis={axis!r}) is not supported \"\n            \"because it is order-sensitive. Only fillna(method=None) is \"\n            f\"supported with axis={axis!r}.\",\n            reason=\"order-sensitive\")\n      if limit is not None:\n        raise frame_base.WontImplementError(\n            f\"fillna(limit={method!r}, axis={axis!r}) is not supported because \"\n            \"it is order-sensitive. Only fillna(limit=None) is supported with \"\n            f\"axis={axis!r}.\",\n            reason=\"order-sensitive\")\n\n    if isinstance(self, DeferredDataFrame) and isinstance(value,\n                                                          DeferredSeries):\n      # If self is a DataFrame and value is a Series we want to broadcast value\n      # to all partitions of self.\n      # This is OK, as its index must be the same size as the columns set of\n      # self, so cannot be too large.\n      class AsScalar(object):","sourceCodeStart":260,"sourceCodeEnd":296,"githubUrl":"https://github.com/apache/beam/blob/12126d8942aaf848030c478b4c6a28c6af861c66/sdks/python/apache_beam/dataframe/frames.py#L260-L296","documentation":"apache_beam.dataframe (the Beam DataFrame API) raises this WontImplementError because fillna with a non-None method (e.g. 'ffill'/'bfill') fills values based on the position/order of rows, which the distributed Beam model cannot guarantee. Only method=None (value-based fill) is supported for axis=index/0. The error is a deliberate 'WontImplement' with reason='order-sensitive'.","triggerScenarios":"Calling df.fillna(method='ffill') or df.fillna(method='bfill') (or fillna(method=...) with axis=0/'index', the default axis) on a DeferredDataFrame/DeferredSeries. Also raised when a wrapper of fillna forwards a non-None method.","commonSituations":"Porting existing pandas code to Beam pipelines; forward/backward filling time-series gaps; copy-pasted pandas snippets that use the deprecated method= parameter of pandas fillna.","solutions":["Replace method='ffill'/'bfill' with an explicit value: df.fillna(value=<constant>) which is order-independent.","If forward/backward fill is truly required, collect the data with to_pandas() (non-deferred) and use pandas fillna, then convert back.","Restructure the pipeline to avoid order-dependent semantics, e.g. fill from a separately computed per-key value.","If you genuinely need order-sensitive semantics and accept a non-parallelizable step, use allow_nonparallel=True style fallbacks or a plain pandas stage."],"exampleFix":"// before\ndf = df.fillna(method='ffill')\n// after\ndf = df.fillna(value=0)  # or fill from an explicitly computed per-group value","handlingStrategy":"validation","validationCode":"if getattr(method, '__call__', None) is not None or method in ('ffill', 'bfill', 'pad', 'backfill'):\n    raise ValueError('Use fillna(value=...) with method=None in Beam DataFrame API')","typeGuard":"def is_order_safe_fillna(kwargs) -> bool:\n    return kwargs.get('method', None) is None","tryCatchPattern":"from apache_beam.dataframe import frame_base\ntry:\n    df = df.fillna(method='ffill')\nexcept frame_base.WontImplementError:\n    df = df.fillna(value=0)","preventionTips":["Never pass method= or limit= to fillna in Beam code","Replace fill strategies with explicit value-based fills","Grep legacy pandas code for fillna(method= before porting to Beam"],"tags":["apache-beam","dataframe","pandas","order-sensitive","fillna"],"backgroundTag":"unsupported-operation","analyzedSha":"12126d8942aaf848030c478b4c6a28c6af861c66","analyzedAt":"2026-09-13T01:50:10.254Z","contentChangedAt":"2026-09-13T01:50:10.254Z","schemaVersion":2},"datasetVersion":"2026-09-14T21:17:11.552Z"}