{"record":{"id":"efee0efffeadff44","repo":"pola-rs/polars","slug":"dataframe-how-must-be-one-of-allowed-got","errorCode":null,"errorMessage":"DataFrame `how` must be one of {{{allowed}}}, got {how!r}","messagePattern":"DataFrame `how` must be one of (.+?)\\}\\}, got (.+?)","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"py-polars/src/polars/functions/eager.py","lineNumber":317,"sourceCode":"            out = wrap_df(plr.concat_df_diagonal(elems))\n        elif how == \"diagonal_relaxed\":\n            out = wrap_ldf(\n                plr.concat_lf_diagonal(\n                    [df.lazy() for df in elems],\n                    rechunk=rechunk,\n                    parallel=parallel,\n                    to_supertypes=True,\n                    maintain_order=True,\n                )\n            )._collect_eager(optimizations=QueryOptFlags._eager())\n        elif how == \"horizontal\":\n            out = wrap_df(plr.concat_df_horizontal(elems, strict=True))\n        elif how == \"horizontal_extend\":\n            out = wrap_df(plr.concat_df_horizontal(elems, strict=False))\n        else:\n            allowed = \", \".join(repr(m) for m in get_args(ConcatMethod))\n            msg = f\"DataFrame `how` must be one of {{{allowed}}}, got {how!r}\"\n            raise ValueError(msg)\n\n    elif is_non_empty_sequence_of(elems, pl.LazyFrame):\n        how = _normalize_horizontal_concat(\"concat\", how, strict=strict)\n\n        if how in (\"vertical\", \"vertical_relaxed\"):\n            return wrap_ldf(\n                plr.concat_lf(\n                    elems,\n                    rechunk=rechunk,\n                    parallel=parallel,\n                    to_supertypes=how.endswith(\"relaxed\"),\n                    maintain_order=True,\n                )\n            )\n        elif how in (\"diagonal\", \"diagonal_relaxed\"):\n            return wrap_ldf(\n                plr.concat_lf_diagonal(\n                    elems,","sourceCodeStart":299,"sourceCodeEnd":335,"githubUrl":"https://github.com/pola-rs/polars/blob/fe841f959ef4d2ceefc05a310d33ed7b1ab24e5e/py-polars/src/polars/functions/eager.py#L299-L335","documentation":"When concatenating DataFrames, `how` must be one of the valid `ConcatMethod` literals; any other string raises a ValueError enumerating the allowed values. This is the final else-branch of the DataFrame dispatch in `concat`.","triggerScenarios":"Calling `pl.concat(dfs, how='Horizontal')` (wrong case), `how='hstack'`, or any misspelled/unsupported strategy string on a list of DataFrames.","commonSituations":"Typos or wrong casing in `how`; copy-pasted strategies from other libraries (e.g. pandas `axis=` idioms); using a strategy valid for LazyFrame-only paths on DataFrames.","solutions":["Use one of the allowed strategies: 'vertical', 'vertical_relaxed', 'diagonal', 'diagonal_relaxed', 'horizontal', 'horizontal_extend', 'align', or align_* variants","Fix casing/typo in the `how` argument","Check `typing.get_args(polars.concatenate.ConcatMethod)` for the exact list"],"exampleFix":"// before\npl.concat(dfs, how='hstack')\n// after\npl.concat(dfs, how='horizontal')","handlingStrategy":"validation","validationCode":"from typing import get_args\nfrom polars.type_aliases import ConcatMethod\nif how not in get_args(ConcatMethod):\n    raise ValueError(f'invalid how={how!r}')","typeGuard":"def is_valid_how(how: str) -> bool:\n    from typing import get_args\n    from polars.type_aliases import ConcatMethod\n    return how in get_args(ConcatMethod)","tryCatchPattern":"try:\n    result = pl.concat(dfs, how=how)\nexcept ValueError as e:\n    if 'DataFrame `how` must be one of' in str(e):\n        result = pl.concat(dfs, how='vertical')\n    else:\n        raise","preventionTips":["Use the ConcatMethod Literal type annotation so static checkers catch bad values","Copy strategy names from documentation, not memory","Add an enum/constant list for allowed strategies in shared code"],"tags":["polars","concat","invalid-enum-value","dataframe"],"backgroundTag":"invalid-enum-value","analyzedSha":"fe841f959ef4d2ceefc05a310d33ed7b1ab24e5e","analyzedAt":"2026-09-18T22:14:11.667Z","contentChangedAt":"2026-09-18T22:14:11.667Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}