pola-rs/polars · error · ValueError

LazyFrame `how` must be one of

Error message

LazyFrame `how` must be one of {{{allowed}}}, got {how!r}

What it means

When concatenating LazyFrames, `how` must be one of the valid `ConcatMethod` literals supported by the lazy path; an unrecognized string raises a ValueError listing allowed values. This is the final else-branch of the LazyFrame dispatch in `concat`.

Solutions

  1. Use a valid strategy such as 'vertical', 'vertical_relaxed', 'diagonal', 'horizontal', 'align', etc.
  2. Fix the typo/casing of `how`
  3. Collect LazyFrames to DataFrames if a strictly eager-only strategy is required

Example fix

// before
pl.concat(lfs, how='vertical-relaxed')
// after
pl.concat(lfs, how='vertical_relaxed')
Defensive patterns

Strategy: validation

Validate before calling

allowed = {'vertical', 'vertical_relaxed', 'diagonal', 'horizontal', 'align', 'align_inner', 'align_full', 'align_left', 'align_right'}
if how not in allowed:
    raise ValueError(f'invalid how={how!r} for LazyFrame concat')

Type guard

def is_valid_lazy_how(how: str) -> bool:
    return how in get_args(ConcatMethod)

Try / catch

try:
    result = pl.concat(lfs, how=how)
except ValueError as e:
    if 'LazyFrame `how` must be one of' in str(e):
        result = pl.concat(lfs, how='vertical')
    else:
        raise

Prevention

When it happens

Trigger: Calling `pl.concat(lfs, how='HorizontalExtend')` or any misspelled/unsupported strategy on a list of LazyFrames after passing the eager-only checks.

Common situations: Typos in `how`; reusing a strategy string from a custom helper; confusion between eager-only and lazy-supported strategies after refactoring eager code to lazy.

Understand the failure class

Background: Invalid enum value errors: "Unknown type", "Invalid scope", "must be one of" — when a string is not on the library's allowed list — this error's family across 23 libraries.

Related errors


AI-assisted analysis of pola-rs/polars@fe841f959e (2026-09-18). Data as JSON: /api/errors/0aa5cb7d56b92f46. Report an issue: GitHub.

Appendix: source

Thrown at py-polars/src/polars/functions/eager.py:361

            return wrap_ldf(
                plr.concat_lf_horizontal(
                    elems,
                    parallel=parallel,
                    strict=True,
                )
            )
        elif how == "horizontal_extend":
            return wrap_ldf(
                plr.concat_lf_horizontal(
                    elems,
                    parallel=parallel,
                    strict=False,
                )
            )
        else:
            allowed = ", ".join(repr(m) for m in get_args(ConcatMethod))
            msg = f"LazyFrame `how` must be one of {{{allowed}}}, got {how!r}"
            raise ValueError(msg)

    elif is_non_empty_sequence_of(elems, pl.Series):
        if how == "vertical":
            out = wrap_s(plr.concat_series(elems))
        else:
            msg = "Series only supports 'vertical' concat strategy"
            raise ValueError(msg)

    elif is_non_empty_sequence_of(elems, pl.Expr):
        return wrap_expr(plr.concat_expr([e._pyexpr for e in elems], rechunk))
    else:
        msg = f"did not expect type: {qualified_type_name(elems[0])!r} in `concat`"
        raise TypeError(msg)

    if rechunk:
        return out.rechunk()
    return out

View on GitHub (pinned to fe841f959e)