Skip to content

Commit

Permalink
docs(python): Add example for Config.set_tbl_width_chars
Browse files Browse the repository at this point in the history
  • Loading branch information
mbuhidar committed Apr 9, 2024
1 parent b91dedb commit 8abb438
Showing 1 changed file with 26 additions and 0 deletions.
26 changes: 26 additions & 0 deletions py-polars/polars/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit 8abb438

Please sign in to comment.