Config#

Config options#

Config.activate_decimals([active])

Activate Decimal data types.

Config.set_ascii_tables([active])

Use ASCII characters to display table outlines (set False to revert to UTF8).

Config.set_fmt_float([fmt])

Control how floating point values are displayed.

Config.set_fmt_str_lengths(n)

Set the number of characters used to display string values.

Config.set_streaming_chunk_size(size)

Overwrite chunk size used in streaming engine.

Config.set_tbl_cell_alignment(format)

Set table cell alignment.

Config.set_tbl_cols(n)

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

Config.set_tbl_column_data_type_inline([active])

Moves the data type inline with the column name (to the right, in parentheses).

Config.set_tbl_dataframe_shape_below([active])

Print the dataframe shape below the dataframe when displaying tables.

Config.set_tbl_formatting([format, ...])

Set table formatting style.

Config.set_tbl_hide_column_data_types([active])

Hide table column data types (i64, f64, str etc.).

Config.set_tbl_hide_column_names([active])

Hide table column names.

Config.set_tbl_hide_dataframe_shape([active])

Hide the shape information of the dataframe when displaying tables.

Config.set_tbl_hide_dtype_separator([active])

Hide the '---' separator between the column names and column types.

Config.set_tbl_rows(n)

Set the max number of rows used to draw the table (both Dataframe and Series).

Config.set_tbl_width_chars(width)

Set the number of characters used to draw the table.

Config.set_verbose([active])

Enable additional verbose/debug logging.

Config load, save, and current state#

Config.load(cfg)

Load and set previously saved (or shared) Config options from json/file.

Config.save([file])

Save the current set of Config options as a json string or file.

Config.state([if_set, env_only])

Show the current state of all Config variables as a dict.

Config.restore_defaults()

Reset all polars Config settings to their default state.

Use as a context manager#

Note that Config supports setting context-scoped options. These options are valid only during scope lifetime, and are reset to their initial values (whatever they were before entering the new context) on scope exit.

You can take advantage of this by initialising a``Config`` instance and then explicitly calling one or more of the available “set_” methods on it…

with pl.Config() as cfg:
    cfg.set_verbose(True)
    do_various_things()

# on scope exit any modified settings are restored to their previous state

…or, often cleaner, by setting the options in the Config init directly (optionally omitting the “set_” prefix for brevity):

with pl.Config(verbose=True):
    do_various_things()

Use as a function decorator#

In the same vein, you can also use Config as a function decorator to temporarily set options for the duration of the function call:

@pl.Config(set_ascii_tables=True)
def write_ascii_frame_to_stdout(df: pl.DataFrame) -> None:
    sys.stdout.write(str(df))

“””