pola-rs/polars · error · ValueError
`strict` cannot be used with `how='horizontal_extend'`
Error message
`strict` cannot be used with `how='horizontal_extend'`
What it means
`pl.concat` with `how='horizontal_extend'` pads shorter frames with nulls, and the padding behavior is inherently non-strict, so the `strict` parameter has no meaningful value there. Polars raises this ValueError in `_normalize_horizontal_concat` to stop ambiguous combinations instead of silently ignoring `strict`.
Solutions
- Remove the `strict` argument when using `how='horizontal_extend'`
- If strict column matching is needed, use `how='horizontal'` instead
- If null-padding lenient behavior is needed, just use `how='horizontal_extend'` alone
Example fix
// before pl.concat([df1, df2], how='horizontal_extend', strict=False) // after pl.concat([df1, df2], how='horizontal_extend')
Defensive patterns
Strategy: validation
Validate before calling
if how == 'horizontal_extend' and strict is not None:
raise ValueError("strict cannot be used with how='horizontal_extend'") Type guard
def is_valid_combo(how: str, strict: bool | None) -> bool:
return not (how == 'horizontal_extend' and strict is not None) Try / catch
try:
out = pl.concat(frames, how='horizontal_extend', strict=strict)
except ValueError as e:
if 'strict' in str(e):
out = pl.concat(frames, how='horizontal_extend')
else:
raise Prevention
- Never pass `strict` together with 'horizontal_extend'
- Centralize concat calls in a helper that normalizes arguments
- Pin Polars version and read changelog when `strict` semantics change
When it happens
Trigger: Calling `pl.concat(frames, how='horizontal_extend', strict=True)` (or `strict=False`) — any non-None `strict` combined with `how='horizontal_extend'` raises immediately, before any frame inspection.
Common situations: Code that worked with `how='horizontal'` and `strict=False` (which historically allowed mismatched column sets) migrated to `'horizontal_extend'` while keeping the `strict` argument; also arises after upgrading Polars where `strict` was newly added to horizontal concat.
Understand the failure class
Background: Conflicting config options: "cannot be used together" — configuration validation errors across open-source libraries — this error's family across 162 libraries.
Related errors
- DataFrame `how` must be one of
- {}
- cannot concat empty list
- cannot create DataFrame from array with more than two…
- cannot initialize Series from DataFrame without any columns
AI-assisted analysis of pola-rs/polars@fe841f959e (2026-09-18).
Data as JSON: /api/errors/6c41ca666b00a11d.
Report an issue: GitHub.
Appendix: source
Thrown at py-polars/src/polars/functions/eager.py:57
case None:
return "horizontal"
case True:
issue_deprecation_warning(
f"the `strict` parameter for `{function_name}` is deprecated. "
"`how='horizontal'` already requires equal heights; omit `strict`.",
version="2.0.0",
)
return "horizontal"
case False:
msg = (
"`strict=False` is no longer supported for `how='horizontal'`. "
"Use `how='horizontal_extend'` to pad shorter frames with `null`."
)
raise ValueError(msg)
if how == "horizontal_extend" and strict is not None:
msg = "`strict` cannot be used with `how='horizontal_extend'`"
raise ValueError(msg)
return how
def concat(
items: Iterable[PolarsType],
*,
how: ConcatMethod = "vertical",
rechunk: bool = False,
parallel: bool = True,
strict: bool | None = None,
) -> PolarsType:
"""
Combine multiple DataFrames, LazyFrames, or Series into a single object.
Parameters
----------
itemsView on GitHub (pinned to fe841f959e)