polars.Config.set_tbl_cols#

classmethod Config.set_tbl_cols(n: int) type[polars.config.Config][source]#

Set the number of columns that are visible when displaying tables.

Parameters:
nint

number of columns to display; if n < 0 (eg: -1), display all columns.

Examples

Set number of displayed columns to a low value:

>>> with pl.Config() as cfg:
...     cfg.set_tbl_cols(5)
...     df = pl.DataFrame({str(i): [i] for i in range(100)})
...     print(df)
...
<class 'polars.config.Config'>
shape: (1, 100)
┌─────┬─────┬─────┬───┬─────┬─────┐
│ 0   ┆ 1   ┆ 2   ┆ … ┆ 98  ┆ 99  │
│ --- ┆ --- ┆ --- ┆   ┆ --- ┆ --- │
│ i64 ┆ i64 ┆ i64 ┆   ┆ i64 ┆ i64 │
╞═════╪═════╪═════╪═══╪═════╪═════╡
│ 0   ┆ 1   ┆ 2   ┆ … ┆ 98  ┆ 99  │
└─────┴─────┴─────┴───┴─────┴─────┘
>>> with pl.Config(tbl_cols=10):
...     print(df)
...
shape: (1, 100)
┌─────┬─────┬─────┬─────┬─────┬───┬─────┬─────┬─────┬─────┬─────┐
│ 0   ┆ 1   ┆ 2   ┆ 3   ┆ 4   ┆ … ┆ 95  ┆ 96  ┆ 97  ┆ 98  ┆ 99  │
│ --- ┆ --- ┆ --- ┆ --- ┆ --- ┆   ┆ --- ┆ --- ┆ --- ┆ --- ┆ --- │
│ i64 ┆ i64 ┆ i64 ┆ i64 ┆ i64 ┆   ┆ i64 ┆ i64 ┆ i64 ┆ i64 ┆ i64 │
╞═════╪═════╪═════╪═════╪═════╪═══╪═════╪═════╪═════╪═════╪═════╡
│ 0   ┆ 1   ┆ 2   ┆ 3   ┆ 4   ┆ … ┆ 95  ┆ 96  ┆ 97  ┆ 98  ┆ 99  │
└─────┴─────┴─────┴─────┴─────┴───┴─────┴─────┴─────┴─────┴─────┘