pola-rs/polars · error

Can not set `ascii_tables` and `tbl_formatting` at the same

Error message

Can not set `ascii_tables` and `tbl_formatting` at the same time.

What it means

DataFrame.show renders the frame with configurable table styling. ascii_tables is a convenience boolean that expands to tbl_formatting='ASCII_FULL_CONDENSED' (True) or 'UTF8_FULL_CONDENSED' (False); since both settings write the same underlying style, passing ascii_tables together with an explicit tbl_formatting is ambiguous and rejected with this ValueError.

Source

Thrown at py-polars/src/polars/dataframe/frame.py:13212

        │ i64 ┆ i64 ┆ str │
        ╞═════╪═════╪═════╡
        │ 1   ┆ 6   ┆ a   │
        │ 2   ┆ 7   ┆ b   │
        └─────┴─────┴─────┘
        """
        if limit is None:
            df = self
            tbl_rows = -1
        else:
            df = self.head(limit)
            if limit < 0:
                tbl_rows = self.height - abs(limit)
            else:
                tbl_rows = limit

        if ascii_tables is not None and tbl_formatting is not None:
            msg = "Can not set `ascii_tables` and `tbl_formatting` at the same time."
            raise ValueError(msg)
        if ascii_tables is not None:
            if ascii_tables:
                tbl_formatting = "ASCII_FULL_CONDENSED"
            else:
                tbl_formatting = "UTF8_FULL_CONDENSED"

        with Config(
            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,

View on GitHub (pinned to df599052da)

Solutions

  1. Drop ascii_tables and express the style directly: tbl_formatting='ASCII_FULL_CONDENSED' reproduces ascii_tables=True
  2. Or drop tbl_formatting and keep ascii_tables if only the ascii/utf8 toggle matters
  3. When splatting option dicts, remove the conflicting key first: opts.pop('ascii_tables', None)

Example fix

# before
df.show(10, ascii_tables=True, tbl_formatting='ASCII_MARKDOWN')

# after
df.show(10, tbl_formatting='ASCII_MARKDOWN')
Defensive patterns

Strategy: validation

Validate before calling

if 'ascii_tables' in opts and 'tbl_formatting' in opts:
    del opts['ascii_tables']  # prefer the explicit named style
out = df.show(limit, **opts)

Prevention

When it happens

Trigger: df.show(10, ascii_tables=True, tbl_formatting='ASCII_MARKDOWN'); splatting a shared options dict into show(**opts) where both keys are present; copying a full option set from other table-config APIs into show.

Common situations: Config-driven rendering where merged defaults from multiple sources leave both keys set; README/wiki snippets that combine the convenience flag with a named style; upgrading code that previously used only one of the two.

Related errors


AI-assisted analysis of pola-rs/polars@df599052da (2026-08-16). Data as JSON: /api/errors/ee21dd89e8bdc9ff. Report an issue: GitHub.