Config#
Config options#
|
Use ASCII characters to display table outlines. |
|
Allow multi-output expressions to be automatically turned into Structs. |
|
Set the decimal separator character. |
|
Control the number of decimal places displayed for floating point values. |
|
Control how floating point values are displayed. |
Set the number of characters used to display string values. |
|
Set the number of elements to display for List values. |
|
Overwrite chunk size used in |
|
|
Set table cell alignment. |
Set table cell alignment for numeric columns. |
|
Set the number of columns that are visible when displaying tables. |
|
|
Moves the data type inline with the column name (to the right, in parentheses). |
|
Print the DataFrame shape information below the data when displaying tables. |
|
Set table formatting style. |
|
Hide table column data types (i64, f64, str etc.). |
|
Hide table column names. |
|
Hide the DataFrame shape information when displaying tables. |
|
Hide the '---' separator between the column names and column types. |
Set the max number of rows used to draw the table (both Dataframe and Series). |
|
|
Set the maximum width of a table in characters. |
|
Set the thousands grouping separator character. |
|
Strip trailing zeros from Decimal data type values. |
|
Enable additional verbose/debug logging. |
Config load, save, state#
|
Load (and set) previously saved Config options from a JSON string. |
|
Load (and set) previously saved Config options from file. |
Save the current set of Config options as a JSON string. |
|
|
Save the current set of Config options as a JSON file. |
|
Show the current state of all Config variables as a dict. |
Reset all polars Config settings to their default state. |
While it is easy to restore all configuration options to their default
value using restore_defaults
, it can also be useful to reset individual
options. This can be done by setting the related value to None
, eg:
pl.Config.set_tbl_rows(None)
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 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))