polars.Config.set_tbl_cell_alignment#

classmethod Config.set_tbl_cell_alignment(
format: Literal['LEFT', 'CENTER', 'RIGHT'] | None,
) type[Config][source]#

设置表格单元格对齐方式。

Parameters:
formatstr
  • “LEFT”: 左对齐

  • “CENTER”: 居中对齐

  • “RIGHT”: 右对齐

Raises:
ValueError: if alignment string not recognised.

示例

>>> df = pl.DataFrame(
...     {"column_abc": [1.0, 2.5, 5.0], "column_xyz": [True, False, True]}
... )
>>> pl.Config.set_tbl_cell_alignment("RIGHT")  
>>> print(df)
shape: (3, 2)
┌────────────┬────────────┐
│ column_abc ┆ column_xyz │
│        --- ┆        --- │
│        f64 ┆       bool │
╞════════════╪════════════╡
│        1.0 ┆       true │
│        2.5 ┆      false │
│        5.0 ┆       true │
└────────────┴────────────┘