polars.DataFrame.show#

DataFrame.show(
limit: int | None = 5,
*,
ascii_tables: bool | None = None,
decimal_separator: str | None = None,
thousands_separator: str | bool | None = None,
float_precision: int | None = None,
fmt_float: FloatFmt | None = None,
fmt_str_lengths: int | None = None,
fmt_table_cell_list_len: int | None = None,
tbl_cell_alignment: Literal['LEFT', 'CENTER', 'RIGHT'] | None = None,
tbl_cell_numeric_alignment: Literal['LEFT', 'CENTER', 'RIGHT'] | None = None,
tbl_cols: int | None = None,
tbl_column_data_type_inline: bool | None = None,
tbl_dataframe_shape_below: bool | None = None,
tbl_formatting: TableFormatNames | None = None,
tbl_hide_column_data_types: bool | None = None,
tbl_hide_column_names: bool | None = None,
tbl_hide_dtype_separator: bool | None = None,
tbl_hide_dataframe_shape: bool | None = None,
tbl_width_chars: int | None = None,
trim_decimal_zeros: bool | None = True,
) None[source]#

Show the first n rows.

Parameters:
limitint

Numbers of rows to show. If a negative value is passed, return all rows except the last abs(n). If None is passed, return all rows.

ascii_tablesbool

Use ASCII characters to display table outlines. Set False to revert to the default UTF8_FULL_CONDENSED formatting style. See Config.set_ascii_tables() for more information.

decimal_separatorstr

Set the decimal separator character. See Config.set_decimal_separator() for more information.

thousands_separatorstr, bool

Set the thousands grouping separator character. See Config.set_thousands_separator() for more information.

float_precisionint

Number of decimal places to display for floating point values. See Config.set_float_precision() for more information.

fmt_float{“mixed”, “full”}

Control how floating point values are displayed. See Config.set_fmt_float() for more information. Supported options are:

  • “mixed”: Limit the number of decimal places and use scientific notation for large/small values.

  • “full”: Print the full precision of the floating point number.

fmt_str_lengthsint

Number of characters to display for string values. See Config.set_fmt_str_lengths() for more information.

fmt_table_cell_list_lenint

Number of elements to display for List values. See Config.set_fmt_table_cell_list_len() for more information.

tbl_cell_alignmentstr

Set table cell alignment. See Config.set_tbl_cell_alignment() for more information. Supported options are:

  • “LEFT”: left aligned

  • “CENTER”: center aligned

  • “RIGHT”: right aligned

tbl_cell_numeric_alignmentstr

Set table cell alignment for numeric columns. See Config.set_tbl_cell_numeric_alignment() for more information. Supported options are:

  • “LEFT”: left aligned

  • “CENTER”: center aligned

  • “RIGHT”: right aligned

tbl_colsint

Number of columns to display. See Config.set_tbl_cols() for more information.

tbl_column_data_type_inlinebool

Moves the data type inline with the column name (to the right, in parentheses). See Config.set_tbl_column_data_type_inline() for more information.

tbl_dataframe_shape_belowbool

Print the DataFrame shape information below the data when displaying tables. See Config.set_tbl_dataframe_shape_below() for more information.

tbl_formattingstr

Set table formatting style. See Config.set_tbl_formatting() for more information. Supported options are:

  • “ASCII_FULL”: ASCII, with all borders and lines, including row dividers.

  • “ASCII_FULL_CONDENSED”: Same as ASCII_FULL, but with dense row spacing.

  • “ASCII_NO_BORDERS”: ASCII, no borders.

  • “ASCII_BORDERS_ONLY”: ASCII, borders only.

  • “ASCII_BORDERS_ONLY_CONDENSED”: ASCII, borders only, dense row spacing.

  • “ASCII_HORIZONTAL_ONLY”: ASCII, horizontal lines only.

  • “ASCII_MARKDOWN”: Markdown format (ascii ellipses for truncated values).

  • “MARKDOWN”: Markdown format (utf8 ellipses for truncated values).

  • “UTF8_FULL”: UTF8, with all borders and lines, including row dividers.

  • “UTF8_FULL_CONDENSED”: Same as UTF8_FULL, but with dense row spacing.

  • “UTF8_NO_BORDERS”: UTF8, no borders.

  • “UTF8_BORDERS_ONLY”: UTF8, borders only.

  • “UTF8_HORIZONTAL_ONLY”: UTF8, horizontal lines only.

  • “NOTHING”: No borders or other lines.

tbl_hide_column_data_typesbool

Hide table column data types (i64, f64, str etc.). See Config.set_tbl_hide_column_data_types() for more information.

tbl_hide_column_namesbool

Hide table column names. See Config.set_tbl_hide_column_names() for more information.

tbl_hide_dtype_separatorbool

Hide the ‘—’ separator between the column names and column types. See Config.set_tbl_hide_dtype_separator() for more information.

tbl_hide_dataframe_shapebool

Hide the DataFrame shape information when displaying tables. See Config.set_tbl_hide_dataframe_shape() for more information.

tbl_width_charsint

Set the maximum width of a table in characters. See Config.set_tbl_width_chars() for more information.

trim_decimal_zerosbool

Strip trailing zeros from Decimal data type values. See Config.set_trim_decimal_zeros() for more information.

See also

head

Examples

>>> df = pl.DataFrame(
...     {
...         "foo": [1, 2, 3, 4, 5],
...         "bar": [6, 7, 8, 9, 10],
...         "ham": ["a", "b", "c", "d", "e"],
...     }
... )
>>> df.show(3)
shape: (3, 3)
┌─────┬─────┬─────┐
│ foo ┆ bar ┆ ham │
│ --- ┆ --- ┆ --- │
│ i64 ┆ i64 ┆ str │
╞═════╪═════╪═════╡
│ 1   ┆ 6   ┆ a   │
│ 2   ┆ 7   ┆ b   │
│ 3   ┆ 8   ┆ c   │
└─────┴─────┴─────┘

Pass a negative value to get all rows except the last abs(n).

>>> df.show(-3)
shape: (2, 3)
┌─────┬─────┬─────┐
│ foo ┆ bar ┆ ham │
│ --- ┆ --- ┆ --- │
│ i64 ┆ i64 ┆ str │
╞═════╪═════╪═════╡
│ 1   ┆ 6   ┆ a   │
│ 2   ┆ 7   ┆ b   │
└─────┴─────┴─────┘