Skip to content

Display

Utilities for displaying text, tables, and plots in Pandas Checks in both terminal and IPython/Jupyter environments.

_display_check(data, name=None)

Renders the result of a Pandas Checks method.

Parameters:

Name Type Description Default
data Any

The data to display, whether a DataFrame, Series, string, or other printable.

required
name Union[str, None]

The optional name of the check.

None

Returns:

Type Description
None

None

_display_line(line, lead_in=None, colors={})

Displays a line of text with optional formatting.

Parameters:

Name Type Description Default
line str

The text to display.

required
lead_in Union[str, None]

The optional text to display before the main text.

None
colors Dict

An optional dictionary containing color options for the text and lead-in text. See syntax in docstring for _render_text().

{}

Returns:

Type Description
None

None

_display_plot()

Renders the active Pandas Checks matplotlib plot object in an IPython/Jupyter environment with an optional indent.

Returns:

Type Description
None

None

Note

It assumes the plot has already been drawn by another function, such as with .plot() or .hist().

_display_plot_title(line, lead_in=None, colors={})

Displays a plot title with optional formatting.

Parameters:

Name Type Description Default
line str

The title text to display.

required
lead_in Union[str, None]

Optional text to display before the title.

None
colors Dict

An optional dictionary containing color settings for the text and lead-in text. See details in docstring for _render_text().

{}

Returns:

Type Description
None

None

_display_router(data, data_for_print_fn=None, bypass_print_fn=False)

Renders content to the output destination(s) as configured globally, including rich content such as plots in IPython/Jupyter environments.

Parameters:

Name Type Description Default
data Any

A displayable object, such as a string, DataFrame, Series, or plot.

required
data_for_print_fn Union[str, None]

Optional, simplied version of text to display when data is formatted HTML (so it doesn't look odd when print_fn is logging.info, for example).

None
bypass_print_fn bool

Optional flag to disable printing to custom_print_fn. Used when we want to display data (such as a plot title) in IPython/Jupyter but not in a logger or other custom_print_fn (since plots aren't logged).

False

Returns:

Type Description
None

None

_display_table(table, title)

Renders a Pandas DataFrame or Series in an IPython/Jupyter environment with an optional indent.

Parameters:

Name Type Description Default
table Union[DataFrame, Series]

The DataFrame or Series to display.

required
title Union[str, None]

Optional title for the table.

required

Returns:

Type Description
None

None

_display_table_title(line, lead_in=None, colors={})

Displays a table title with optional formatting.

Parameters:

Name Type Description Default
line str

The title text to display.

required
lead_in Union[str, None]

Optional text to display before the title.

None
colors Dict

An optiona dictionary containing color options for the text and lead-in text. See details in docstring for _render_text()

{}

Returns:

Type Description
None

None

_filter_emojis(text)

Removes emojis from text if user has globally forbidden them.

Parameters:

Name Type Description Default
text str

The text to filter emojis from.

required

Returns:

Type Description
str

The text with emojis removed if the user's global settings do not allow emojis. Else, the original text.

_format_background_color(color)

Applies a background color to text used being displayed in the terminal.

Parameters:

Name Type Description Default
color str

The background color to format. See syntax in docstring for _render_text().

required

Returns:

Type Description
str

The formatted background color.

_lead_in(lead_in, foreground, background)

Formats a lead-in text with colors.

Parameters:

Name Type Description Default
lead_in Union[str, None]

The lead-in text to format.

required
foreground str

The foreground color for the lead-in text. See syntax in docstring for _render_text().

required
background str

The background color for the lead-in text. See syntax in docstring for _render_text().

required

Returns:

Type Description
str

The formatted lead-in text.

_print_router(text, custom_print_fn_only=False, text_for_print_fn=None, bypass_print_fn=False)

Prints given text to the output destination(s) as configured globally.

Parameters:

Name Type Description Default
text Union[str, None]

The text to print.

required
custom_print_fn_only bool

Whether to only call the custom print function if it exists, without attempting to print to standard output. Used when _print_router() is called only to access custom_print_fn.

False
text_for_print_fn Union[str, None]

Optional, simplied version of text to display without colors (so it doesn't look odd when print_fn is logging.info, for example).

None
bypass_print_fn bool

Optional flag to disable printing to custom_print_fn. Used when we want to display text (such as white space lines) in Terminal but not in a logger or other custom_print_fn.

False

Returns:

Type Description
None

None

_print_table(table, title, custom_print_fn_only=False)

Prints a Pandas table in a terminal with an optional indent.

Parameters:

Name Type Description Default
table Union[DataFrame, Series]

A DataFrame or Series.

required

Returns:

Type Description
None

None

_render_html_with_indent(object_as_html)

Renders HTML with an optional indent.

Parameters:

Name Type Description Default
object_as_html str

The HTML to render.

required

Returns:

Type Description
None

None

_render_text(text, tag, lead_in=None, colors={}, bypass_print_fn=False)

Renders text with optional formatting.

Parameters:

Name Type Description Default
text str

The text to render.

required
tag str

The HTML tag to use for rendering.

required
lead_in Union[str, None]

Optional text to display before the main text.

None
colors Dict

Optional colors for the text and lead-in text. Keys include: - text_color: The foreground color of the main text. - text_background_color: The background or highlight color of the main text. - lead_in_text_color: The foreground color of lead-in text. - lead_in_background_color: The background color of lead-in text. Color values are phrased such as "blue" or "white". They are passed to either HTML for Jupyter/IPython outputs and to termcolor when code is run in terminal. For color options when code is run in terminal, see https://github.com/termcolor/termcolor.

{}
bypass_print_fn bool

Optional flag to decide whether the text should also be sent to the global custom print function, if it exists. See _display_router() for details.

False

Returns:

Type Description
None

None

_warning(message, lead_in='🐼🩺 Pandas Checks warning', clean_type=False)

Displays a warning message.

Parameters:

Name Type Description Default
message str

The warning message to display.

required
lead_in str

Optional lead-in text to display before the warning message.

'🐼🩺 Pandas Checks warning'
clean_type bool

Optional flag to remove the class type from the message, when running .check.dtype().

False

Returns:

Type Description
None

None