{"record":{"id":"9c31e11494dc1c1a","repo":"pola-rs/polars","slug":"series-only-supports-vertical-concat-strategy","errorCode":null,"errorMessage":"Series only supports 'vertical' concat strategy","messagePattern":"Series only supports 'vertical' concat strategy","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"py-polars/src/polars/functions/eager.py","lineNumber":368,"sourceCode":"        elif how == \"horizontal_extend\":\n            return wrap_ldf(\n                plr.concat_lf_horizontal(\n                    elems,\n                    parallel=parallel,\n                    strict=False,\n                )\n            )\n        else:\n            allowed = \", \".join(repr(m) for m in get_args(ConcatMethod))\n            msg = f\"LazyFrame `how` must be one of {{{allowed}}}, got {how!r}\"\n            raise ValueError(msg)\n\n    elif is_non_empty_sequence_of(elems, pl.Series):\n        if how == \"vertical\":\n            out = wrap_s(plr.concat_series(elems))\n        else:\n            msg = \"Series only supports 'vertical' concat strategy\"\n            raise ValueError(msg)\n\n    elif is_non_empty_sequence_of(elems, pl.Expr):\n        return wrap_expr(plr.concat_expr([e._pyexpr for e in elems], rechunk))\n    else:\n        msg = f\"did not expect type: {qualified_type_name(elems[0])!r} in `concat`\"\n        raise TypeError(msg)\n\n    if rechunk:\n        return out.rechunk()\n    return out\n\n\ndef union(\n    items: Iterable[PolarsType],\n    *,\n    how: ConcatMethod = \"vertical\",\n    strict: bool | None = None,\n) -> PolarsType:","sourceCodeStart":350,"sourceCodeEnd":386,"githubUrl":"https://github.com/pola-rs/polars/blob/fe841f959ef4d2ceefc05a310d33ed7b1ab24e5e/py-polars/src/polars/functions/eager.py#L350-L386","documentation":"Series can only be concatenated with the 'vertical' strategy (stacking end-to-end); any other `how` raises ValueError. Polars does not implement horizontal or diagonal concat for Series because they have no columns.","triggerScenarios":"Calling `pl.concat([s1, s2], how='diagonal')` or any strategy other than 'vertical' on a sequence of Series.","commonSituations":"Copy-pasting a DataFrame concat call and only swapping in Series; attempting to 'hstack' Series (use `pl.DataFrame([...])` or `DataFrame.hstack` instead); generic concat wrappers that pass `how` through unconditionally.","solutions":["Use `pl.concat(series_list, how='vertical')`","Build a DataFrame and use `hstack` for horizontal combination of Series","Make the `how` parameter conditional on element type in generic wrappers"],"exampleFix":"// before\npl.concat([s1, s2], how='horizontal')\n// after\npl.concat([s1, s2], how='vertical')","handlingStrategy":"validation","validationCode":"if not all(isinstance(x, pl.Series) for x in items):\n    raise TypeError('expected Series')\nif how != 'vertical':\n    raise ValueError(\"Series concat only supports how='vertical'\")\nresult = pl.concat(items, how='vertical')","typeGuard":"def are_series(items: list) -> bool:\n    return bool(items) and all(isinstance(x, pl.Series) for x in items)","tryCatchPattern":"try:\n    result = pl.concat(series_list, how=how)\nexcept ValueError as e:\n    if 'vertical' in str(e):\n        result = pl.concat(series_list, how='vertical')\n    else:\n        raise","preventionTips":["Hard-code how='vertical' for Series concat","Use DataFrame.hstack for side-by-side Series combination","Make wrappers type-aware before forwarding `how`"],"tags":["polars","series","concat","unsupported-strategy"],"backgroundTag":"unsupported-operation","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"}