{"record":{"id":"1f6f0fd8a2aad730","repo":"apache/beam","slug":"align-axis-must-be-one-of-index-0-columns-1-got-align-axis-r","errorCode":null,"errorMessage":"align_axis must be one of ('index', 0, 'columns', 1). got {align_axis!r}.","messagePattern":"align_axis must be one of \\('index', 0, 'columns', 1\\)\\. got (.+?)\\.","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"sdks/python/apache_beam/dataframe/frames.py","lineNumber":2471,"sourceCode":"          reason=\"order-sensitive\")\n    else:\n      raise TypeError(\n          \"repeat(repeats=) value must be an int or a \"\n          f\"DeferredSeries (encountered {type(repeats)}).\")\n\n  if hasattr(pd.Series, 'compare'):\n\n    @frame_base.with_docs_from(pd.Series)\n    @frame_base.args_to_kwargs(pd.Series)\n    @frame_base.populate_defaults(pd.Series)\n    def compare(self, other, align_axis, **kwargs):\n\n      if align_axis in ('index', 0):\n        preserves_partition = partitionings.Singleton()\n      elif align_axis in ('columns', 1):\n        preserves_partition = partitionings.Arbitrary()\n      else:\n        raise ValueError(\n            \"align_axis must be one of ('index', 0, 'columns', 1). \"\n            f\"got {align_axis!r}.\")\n\n      return frame_base.DeferredFrame.wrap(\n          expressions.ComputedExpression(\n              'compare',\n              lambda s, other: s.compare(other, align_axis, **kwargs),\n              [self._expr, other._expr],\n              requires_partition_by=partitionings.Index(),\n              preserves_partition_by=preserves_partition))\n\n\n@populate_not_implemented(pd.DataFrame)\n@frame_base.DeferredFrame._register_for(pd.DataFrame)\nclass DeferredDataFrame(DeferredDataFrameOrSeries):\n  def __repr__(self):\n    return (\n        f'DeferredDataFrame(columns={list(self.columns)}, '","sourceCodeStart":2453,"sourceCodeEnd":2489,"githubUrl":"https://github.com/apache/beam/blob/12126d8942aaf848030c478b4c6a28c6af861c66/sdks/python/apache_beam/dataframe/frames.py#L2453-L2489","documentation":"DeferredSeries.compare accepts an align_axis parameter that must be one of 'index', 0, 'columns', or 1, mirroring pandas. The Beam implementation dispatches partitioning behavior on this value; anything else means it cannot be mapped, so a ValueError is raised naming the allowed values.","triggerScenarios":"Calling s1.compare(s2, align_axis='Index') (wrong case), align_axis=2, align_axis=None, or any value outside {'index', 0, 'columns', 1}.","commonSituations":"Porting pandas compare() calls where align_axis was read from config or computed dynamically; typos like 'rows'/'cols' instead of the pandas-legal values.","solutions":["Pass align_axis='index' (or 0) to stack differences vertically.","Pass align_axis='columns' (or 1) to keep the original column layout.","Fix casing/whitespace: 'Index' or 'index ' is invalid; print repr(align_axis) to debug.","Guard the value before calling: if align_axis not in ('index', 0, 'columns', 1): raise/normalize."],"exampleFix":"// before\ndf1.compare(df2, align_axis='rows')  # invalid\n// after\ndf1.compare(df2, align_axis='columns')","handlingStrategy":"validation","validationCode":"VALID = ('index', 0, 'columns', 1)\nif align_axis not in VALID:\n    raise ValueError(f'align_axis must be one of {VALID}')","typeGuard":"def is_valid_align_axis(v) -> bool:\n    return v in ('index', 0, 'columns', 1)","tryCatchPattern":"try:\n    diff = s1.compare(s2, align_axis=align_axis)\nexcept ValueError:\n    diff = s1.compare(s2, align_axis='columns')","preventionTips":["Only pass literal 'index'/0/'columns'/1 for align_axis.","Watch casing: 'Index' and 'Columns' are invalid.","Do not compute align_axis from external config without normalizing it.","Test compare() calls with both axis values after pandas version upgrades."],"tags":["python","apache-beam","dataframe","invalid-argument-value"],"backgroundTag":"invalid-enum-value","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"}