polars.Config.set_thousands_separator#

classmethod Config.set_thousands_separator(
separator: str | bool | None = None,
) type[Config][source]#

Set the thousands grouping separator character.

Parameters:
separatorstr, bool

Set True to use the default “,” (thousands) and “.” (decimal) separators. Can also set a custom char, or set None to omit the separator.

See also

set_decimal_separator

Set the decimal separator character.

Examples

>>> df = pl.DataFrame(
...     {
...         "x": [1234567, -987654, 10101],
...         "y": [1234.5, 100000.0, -7654321.25],
...     }
... )
>>> with pl.Config(
...     tbl_cell_numeric_alignment="RIGHT",
...     thousands_separator=True,
...     float_precision=2,
... ):
...     print(df)
shape: (3, 2)
┌───────────┬───────────────┐
│         x ┆             y │
│       --- ┆           --- │
│       i64 ┆           f64 │
╞═══════════╪═══════════════╡
│ 1,234,567 ┆      1,234.50 │
│  -987,654 ┆    100,000.00 │
│    10,101 ┆ -7,654,321.25 │
└───────────┴───────────────┘
>>> with pl.Config(
...     tbl_cell_numeric_alignment="RIGHT",
...     thousands_separator=".",
...     decimal_separator=",",
...     float_precision=2,
... ):
...     print(df)
shape: (3, 2)
┌───────────┬───────────────┐
│         x ┆             y │
│       --- ┆           --- │
│       i64 ┆           f64 │
╞═══════════╪═══════════════╡
│ 1.234.567 ┆      1.234,50 │
│  -987.654 ┆    100.000,00 │
│    10.101 ┆ -7.654.321,25 │
└───────────┴───────────────┘