{"record":{"id":"8a5cbc563cb9b861","repo":"apache/beam","slug":"axis-must-be-one-of-0-1-index-columns-got-s","errorCode":null,"errorMessage":"axis must be one of (0, 1, 'index', 'columns'), got '%s'","messagePattern":"axis must be one of \\(0, 1, 'index', 'columns'\\), got '(.+?)'","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"sdks/python/apache_beam/dataframe/frames.py","lineNumber":214,"sourceCode":"  @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 drop(self, labels, axis, index, columns, errors, **kwargs):\n    \"\"\"drop is not parallelizable when dropping from the index and\n    ``errors=\"raise\"`` is specified. It requires collecting all data on a single\n    node in order to detect if one of the index values is missing.\"\"\"\n    if labels is not None:\n      if index is not None or columns is not None:\n        raise ValueError(\"Cannot specify both 'labels' and 'index'/'columns'\")\n      if axis in (0, 'index'):\n        index = labels\n        columns = None\n      elif axis in (1, 'columns'):\n        index = None\n        columns = labels\n      else:\n        raise ValueError(\n            \"axis must be one of (0, 1, 'index', 'columns'), \"\n            \"got '%s'\" % axis)\n\n    if columns is not None:\n      # Compute the proxy based on just the columns that are dropped.\n      proxy = self._expr.proxy().drop(columns=columns, errors=errors)\n    else:\n      proxy = self._expr.proxy()\n\n    if index is not None and errors == 'raise':\n      # In order to raise an error about missing index values, we'll\n      # need to collect the entire dataframe.\n      # TODO: This could be parallelized by putting index values in a\n      # ConstantExpression and partitioning by index.\n      requires = partitionings.Singleton(\n          reason=(\n              \"drop(errors='raise', axis='index') is not currently \"\n              \"parallelizable. This requires collecting all data on a single \"","sourceCodeStart":196,"sourceCodeEnd":232,"githubUrl":"https://github.com/apache/beam/blob/12126d8942aaf848030c478b4c6a28c6af861c66/sdks/python/apache_beam/dataframe/frames.py#L196-L232","documentation":"When drop() is called with labels=, the axis argument determines whether labels refer to the index or columns. If axis is anything other than 0, 1, 'index', or 'columns', this ValueError is raised because the target of the drop cannot be determined.","triggerScenarios":"df.drop(labels=['a'], axis='rows') or df.drop(labels=['a'], axis='column') — an axis string not in the accepted set, passed together with labels=.","commonSituations":"Typos like axis='row'/'cols'; porting from APIs that accept 'rows'/'columns-only' spellings; mixing up the axis convention (axis=1 means columns, not rows).","solutions":["Use one of axis=0, axis=1, axis='index', axis='columns'","Prefer the explicit index= or columns= keywords and omit axis entirely","Remember axis=1/'columns' drops columns; axis=0/'index' drops row labels"],"exampleFix":"# before\ndf.drop(labels='col_a', axis='col')\n# after\ndf.drop(labels='col_a', axis='columns')","handlingStrategy":"validation","validationCode":"VALID_AXES = (0, 1, 'index', 'columns')\nif axis not in VALID_AXES:\n    raise ValueError(f\"axis must be one of {VALID_AXES}\")\nout = df.drop(labels=labels, axis=axis)","typeGuard":"def is_valid_axis(axis):\n    return axis in (0, 1, 'index', 'columns')","tryCatchPattern":"try:\n    out = df.drop(labels=labels, axis=axis)\nexcept ValueError:\n    out = df.drop(labels=labels, axis='columns' if str(axis).startswith('col') else 'index')","preventionTips":["Use only 0/1/'index'/'columns' — not 'rows'/'row'/'cols'","Prefer index=/columns= keywords to avoid axis entirely","Remember axis=1 means columns in pandas"],"tags":["python","apache-beam","dataframe","axis-argument"],"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"}