diff --git a/py-polars/polars/config.py b/py-polars/polars/config.py index 0aabe4d59a6a..de05fa7421f1 100644 --- a/py-polars/polars/config.py +++ b/py-polars/polars/config.py @@ -1195,6 +1195,32 @@ def set_tbl_width_chars(cls, width: int | None) -> type[Config]: ---------- width : int Maximum table width in characters. + + Examples + -------- + >>> df = pl.DataFrame( + ... { + ... "x": [1234567, -987654, 10101], + ... "y": [1234.5, 100000.0, -7654321.25], + ... } + ... ) + >>> pl.Config.set_tbl_width_chars(16) # doctest: +SKIP + # ... + # shape: (3, 2) shape: (3, 2) + # ┌─────────┬───────────┐ ┌─────┬────────┐ + # │ x ┆ y │ │ x ┆ y │ + # │ --- ┆ --- │ │ --- ┆ --- │ + # │ i64 ┆ f64 │ │ i64 ┆ f64 │ + # ╞═════════╪═══════════╡ >> ╞═════╪════════╡ + # │ 1234567 ┆ 1234.5 │ │ 123 ┆ 1234.5 │ + # │ -987654 ┆ 100000.0 │ │ 456 ┆ │ + # │ 10101 ┆ -7.6543e6 │ │ 7 ┆ │ + # └─────────┴───────────┘ │ -98 ┆ 100000 │ + # │ 765 ┆ .0 │ + # │ 4 ┆ │ + # │ 101 ┆ -7.654 │ + # │ 01 ┆ 3e6 │ + # └─────┴────────┘ """ if width is None: os.environ.pop("POLARS_TABLE_WIDTH", None)