Skip to content

Run checks

Utilities for running Pandas Checks data checks.

SubsetTypes = Union[list, str, int, bool, slice, pd.Index, None] module-attribute

_apply_modifications(data, fn=lambda df: df, subset=None)

Applies user's modifications to a data object.

Parameters:

Name Type Description Default
data Any

May be any Pandas DataFrame, Series, string, or other variable

required
fn Callable

An optional lambda function to modify data

lambda df: df
subset SubsetTypes

Optional column name or names to filter the data to. Applied after fn.

None

Returns:

Type Description
Any

Modified and optionally subsetted data object. If all arguments are defaults, data is returned unchanged.

_check_data(data, check_fn=lambda df: df, modify_fn=lambda df: df, subset=None, msg=None)

Runs a selected check on a data object

Parameters:

Name Type Description Default
data Any

A Pandas DataFrame, Series, string, or other variable

required
check_fn Callable

Function to apply to data for checking. For example if we're running .check.value_counts(), this function would appply the Pandas value_counts() method

lambda df: df
modify_fn Callable

Optional function to modify data before checking

lambda df: df
subset SubsetTypes

Optional column name or names to select before running check_fn

None
msg Union[str, None]

Name to use when displaying check result

None

Returns:

Type Description
None

None

_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

get_mode()

Returns whether Pandas Checks is currently running checks and assertions.

Returns:

Type Description
Dict[str, bool]

A dictionary containing the current settings.