polars.Config.set_tbl_cell_numeric_alignment#

classmethod Config.set_tbl_cell_numeric_alignment(
format: Literal['LEFT', 'CENTER', 'RIGHT'] | None,
) type[Config][source]#

Set table cell alignment for numeric columns.

Parameters:
formatstr
  • “LEFT”: left aligned

  • “CENTER”: center aligned

  • “RIGHT”: right aligned

Raises:
KeyError: if alignment string not recognised.

Examples

>>> from datetime import date
>>> df = pl.DataFrame(
...     {
...         "abc": [11, 2, 333],
...         "mno": [date(2023, 10, 29), None, date(2001, 7, 5)],
...         "xyz": [True, False, None],
...     }
... )
>>> pl.Config.set_tbl_cell_numeric_alignment("RIGHT")
>>> print(df)
shape: (3, 3)
┌─────┬────────────┬───────┐
│ abc ┆ mno        ┆ xyz   │
│ --- ┆ ---        ┆ ---   │
│ i64 ┆ date       ┆ bool  │
╞═════╪════════════╪═══════╡
│  11 ┆ 2023-10-29 ┆ true  │
│   2 ┆ null       ┆ false │
│ 333 ┆ 2001-07-05 ┆ null  │
└─────┴────────────┴───────┘