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
- Drop ascii_tables and express the style directly: tbl_formatting='ASCII_FULL_CONDENSED' reproduces ascii_tables=True
- Or drop tbl_formatting and keep ascii_tables if only the ascii/utf8 toggle matters
- 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
- Pick one styling channel per call: the ascii_tables toggle or a named tbl_formatting style
- When splatting merged option dicts into show(), pop one of the conflicting keys first
- Encode the equivalence ASCII_FULL_CONDENSED <-> ascii_tables=True in your config docs
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
- cannot use `partition_by` with `maintain_order=False, includ
- invalid `return_type`; found {return_type!r}, expected one o
- `offset` input for `with_row_index` cannot be {issue}, got {
- unexpected input for `strategy`: {strategy!r} Choose one of
- cannot specify both `n` and `fraction`
AI-assisted analysis of pola-rs/polars@df599052da (2026-08-16).
Data as JSON: /api/errors/ee21dd89e8bdc9ff.
Report an issue: GitHub.