pola-rs/polars · error · ValueError

`limit` cannot be None. If you want to show the complete…

Error message

`limit` cannot be None. If you want to show the complete lazyframe, call `.collect().show()` on it.

What it means

LazyFrame.show() requires an explicit `limit` because a LazyFrame has no known size; showing everything would force a full unbounded collect. Polars refuses `limit=None` and tells you to collect first if you truly want the complete frame.

Solutions

  1. Pass an explicit integer limit, e.g. lf.show(10)
  2. If you want the full frame displayed, call lf.collect().show() instead
  3. Default your limit variable to a number (e.g. 10) rather than None

Example fix

// before
lf.show(limit=None)
// after
lf.show(10)  # or lf.collect().show() for the full frame
Defensive patterns

Strategy: validation

Validate before calling

if limit is None:
    raise ValueError("pass an explicit limit to LazyFrame.show()")
lf.show(limit)

Try / catch

try:
    lf.show(limit)
except ValueError as e:
    lf.collect().show()

Prevention

When it happens

Trigger: Calling LazyFrame.show() with limit=None, e.g. lf.show() where limit was computed as None or explicitly passed as None.

Common situations: Refactoring from DataFrame.show() (where limit=None is allowed) to LazyFrame.show(); passing a configurable limit variable that defaults to None.

Related errors


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

Appendix: source

Thrown at py-polars/src/polars/lazyframe/frame.py:9590

        │ 2   ┆ 8   │
        │ 3   ┆ 9   │
        │ 4   ┆ 10  │
        │ 5   ┆ 11  │
        └─────┴─────┘
        >>> lf.show(2)
        shape: (2, 2)
        ┌─────┬─────┐
        │ a   ┆ b   │
        │ --- ┆ --- │
        │ i64 ┆ i64 │
        ╞═════╪═════╡
        │ 1   ┆ 7   │
        │ 2   ┆ 8   │
        └─────┴─────┘
        """
        if limit is None:
            msg = "`limit` cannot be None. If you want to show the complete lazyframe, call `.collect().show()` on it."
            raise ValueError(msg)

        self.head(limit).collect(engine="streaming").show(
            limit,
            ascii_tables=ascii_tables,
            decimal_separator=decimal_separator,
            thousands_separator=thousands_separator,
            float_precision=float_precision,
            fmt_float=fmt_float,
            fmt_str_lengths=fmt_str_lengths,
            fmt_table_cell_list_len=fmt_table_cell_list_len,
            tbl_cell_alignment=tbl_cell_alignment,
            tbl_cell_numeric_alignment=tbl_cell_numeric_alignment,
            tbl_cols=tbl_cols,
            tbl_column_data_type_inline=tbl_column_data_type_inline,
            tbl_dataframe_shape_below=tbl_dataframe_shape_below,
            tbl_formatting=tbl_formatting,
            tbl_hide_column_data_types=tbl_hide_column_data_types,
            tbl_hide_column_names=tbl_hide_column_names,

View on GitHub (pinned to fe841f959e)