polars.Config.set_tbl_cols#
- classmethod Config.set_tbl_cols(n: int | None) type[Config][source]#
设置显示表格时可见的列数。
- Parameters:
- nint
显示的列数;如果
n < 0(例如:-1),则显示所有列。
示例
将显示的列数设置为较低的值:
>>> 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 │ └─────┴─────┴─────┴─────┴─────┴───┴─────┴─────┴─────┴─────┴─────┘