Skip to content

Series methods

_obj = pandas_obj instance-attribute

__init__(pandas_obj)

assert_data(condition, pass_message=' ✔️ Assertion passed ', fail_message=' ㄨ Assertion failed ', raise_exception=True, exception_to_raise=DataError, message_shows_condition=True, verbose=False)

Tests whether Series meets condition. Optionally raises an exception. Does not modify the Series itself.

Parameters:

Name Type Description Default
condition Callable

Assertion criteria in the form of a lambda function, such as lambda s: s.shape[0]>10.

required
pass_message str

Message to display if the condition passes.

' ✔️ Assertion passed '
fail_message str

Message to display if the condition fails.

' ㄨ Assertion failed '
raise_exception bool

Whether to raise an exception if the condition fails.

True
exception_to_raise Type[BaseException]

The exception to raise if the condition fails and raise_exception is True.

DataError
message_shows_condition bool

Whether the fail/pass message should also print the assertion criteria

True
verbose bool

Whether to display the pass message if the condition passes.

False

Returns:

Type Description
Series

The original Series, unchanged.

assert_datetime(pass_message=' ✔️ Assert datetime passed ', fail_message=None, raise_exception=True, exception_to_raise=TypeError, verbose=False)

Tests whether Series is datetime or timestamp. Optionally raises an exception. Does not modify the Series itself.

Parameters:

Name Type Description Default
pass_message str

Message to display if the condition passes.

' ✔️ Assert datetime passed '
fail_message Union[str, None]

Message to display if the condition fails.

None
raise_exception bool

Whether to raise an exception if the condition fails.

True
exception_to_raise Type[BaseException]

The exception to raise if the condition fails and raise_exception is True.

TypeError
verbose bool

Whether to display the pass message if the condition passes.

False

Returns:

Type Description
Series

The original Series, unchanged.

assert_float(pass_message=' ✔️ Assert float passed ', fail_message=None, raise_exception=True, exception_to_raise=TypeError, verbose=False)

Tests whether Series is floats. Optionally raises an exception. Does not modify the Series itself.

Parameters:

Name Type Description Default
pass_message str

Message to display if the condition passes.

' ✔️ Assert float passed '
fail_message Union[str, None]

Message to display if the condition fails.

None
raise_exception bool

Whether to raise an exception if the condition fails.

True
exception_to_raise Type[BaseException]

The exception to raise if the condition fails and raise_exception is True.

TypeError
verbose bool

Whether to display the pass message if the condition passes.

False

Returns:

Type Description
Series

The original Series, unchanged.

assert_greater_than(min, or_equal_to=True, pass_message=' ✔️ Assert minimum passed ', fail_message=' ㄨ Assert minimum failed ', raise_exception=True, exception_to_raise=DataError, verbose=False)

Tests whether Series is > or >= a value. Optionally raises an exception. Does not modify the Series itself.

Parameters:

Name Type Description Default
min Any

the minimum value to compare Series to. Accepts any type that can be used in >, such as int, float, str, datetime

required
or_equal_to bool

whether to test for >= min (True) or > min (False)

True
pass_message str

Message to display if the condition passes.

' ✔️ Assert minimum passed '
fail_message str

Message to display if the condition fails.

' ㄨ Assert minimum failed '
raise_exception bool

Whether to raise an exception if the condition fails.

True
exception_to_raise Type[BaseException]

The exception to raise if the condition fails and raise_exception is True.

DataError
verbose bool

Whether to display the pass message if the condition passes.

False

Returns:

Type Description
Series

The original Series, unchanged.

assert_int(pass_message=' ✔️ Assert integeer passed ', fail_message=None, raise_exception=True, exception_to_raise=TypeError, verbose=False)

Tests whether Series is integers. Optionally raises an exception. Does not modify the Series itself.

Args:

pass_message: Message to display if the condition passes.
fail_message: Message to display if the condition fails.
raise_exception: Whether to raise an exception if the condition fails.
exception_to_raise: The exception to raise if the condition fails and raise_exception is True.
verbose: Whether to display the pass message if the condition passes.

Returns:

Type Description
Series

The original Series, unchanged.

assert_less_than(max, or_equal_to=True, pass_message=' ✔️ Assert maximum passed ', fail_message=' ㄨ Assert maximum failed ', raise_exception=True, exception_to_raise=DataError, verbose=False)

Tests whether Series is < or <= a value. Optionally raises an exception. Does not modify the Series itself.

Parameters:

Name Type Description Default
max Any

the max value to compare Series to. Accepts any type that can be used in <, such as int, float, str, datetime

required
or_equal_to bool

whether to test for <= min (True) or < max (False)

True
pass_message str

Message to display if the condition passes.

' ✔️ Assert maximum passed '
fail_message str

Message to display if the condition fails.

' ㄨ Assert maximum failed '
raise_exception bool

Whether to raise an exception if the condition fails.

True
exception_to_raise Type[BaseException]

The exception to raise if the condition fails and raise_exception is True.

DataError
verbose bool

Whether to display the pass message if the condition passes.

False

Returns:

Type Description
Series

The original Series, unchanged.

assert_negative(assert_not_null=True, pass_message=' ✔️ Assert negative passed ', fail_message=' ㄨ Assert negative failed ', raise_exception=True, exception_to_raise=DataError, verbose=False)

Tests whether Series has all negative values. Optionally raises an exception. Does not modify the Series itself.

Parameters:

Name Type Description Default
assert_not_null bool

Whether to also enforce that data has no nulls.

True
pass_message str

Message to display if the condition passes.

' ✔️ Assert negative passed '
fail_message str

Message to display if the condition fails.

' ㄨ Assert negative failed '
raise_exception bool

Whether to raise an exception if the condition fails.

True
exception_to_raise Type[BaseException]

The exception to raise if the condition fails and raise_exception is True.

DataError
verbose bool

Whether to display the pass message if the condition passes.

False

Returns:

Type Description
Series

The original Series, unchanged.

assert_not_null(pass_message=' ✔️ Assert no nulls passed ', fail_message=' ㄨ Assert no nulls failed ', raise_exception=True, exception_to_raise=DataError, verbose=False)

Tests whether Series has no nulls. Optionally raises an exception. Does not modify the Series itself.

Args:

pass_message: Message to display if the condition passes.
fail_message: Message to display if the condition fails.
raise_exception: Whether to raise an exception if the condition fails.
exception_to_raise: The exception to raise if the condition fails and raise_exception is True.
verbose: Whether to display the pass message if the condition passes.

Returns:

Type Description
Series

The original Series, unchanged.

assert_null(pass_message=' ✔️ Assert all nulls passed ', fail_message=' ㄨ Assert all nulls failed ', raise_exception=True, exception_to_raise=DataError, verbose=False)

Tests whether Series has all nulls. Optionally raises an exception. Does not modify the Series itself.

Args:

pass_message: Message to display if the condition passes.
fail_message: Message to display if the condition fails.
raise_exception: Whether to raise an exception if the condition fails.
exception_to_raise: The exception to raise if the condition fails and raise_exception is True.
verbose: Whether to display the pass message if the condition passes.

Returns:

Type Description
Series

The original Series, unchanged.

assert_positive(assert_not_null=True, pass_message=' ✔️ Assert positive passed ', fail_message=' ㄨ Assert positive failed ', raise_exception=True, exception_to_raise=DataError, verbose=False)

Tests whether Series has all positive values. Optionally raises an exception. Does not modify the Series itself.

Args:

assert_not_null: Whether to also enforce that data has no nulls.
pass_message: Message to display if the condition passes.
fail_message: Message to display if the condition fails.
raise_exception: Whether to raise an exception if the condition fails.
exception_to_raise: The exception to raise if the condition fails and raise_exception is True.
verbose: Whether to display the pass message if the condition passes.

Returns:

Type Description
Series

The original Series, unchanged.

assert_str(pass_message=' ✔️ Assert string passed ', fail_message=None, raise_exception=True, exception_to_raise=TypeError, verbose=False)

Tests whether Series is strings. Optionally raises an exception. Does not modify the Series itself.

Args:

pass_message: Message to display if the condition passes.
fail_message: Message to display if the condition fails.
raise_exception: Whether to raise an exception if the condition fails.
exception_to_raise: The exception to raise if the condition fails and raise_exception is True.
verbose: Whether to display the pass message if the condition passes.

Returns:

Type Description
Series

The original Series, unchanged.

assert_timedelta(pass_message=' ✔️ Assert timedelta passed ', fail_message=None, raise_exception=True, exception_to_raise=TypeError, verbose=False)

Tests whether Series is of type timedelta. Optionally raises an exception. Does not modify the Series itself.

Args:

pass_message: Message to display if the condition passes.
fail_message: Message to display if the condition fails.
raise_exception: Whether to raise an exception if the condition fails.
exception_to_raise: The exception to raise if the condition fails and raise_exception is True.
verbose: Whether to display the pass message if the condition passes.

Returns:

Type Description
Series

The original Series, unchanged.

assert_type(dtype, pass_message=' ✔️ Assert type passed ', fail_message=None, raise_exception=True, exception_to_raise=TypeError, verbose=False)

Tests whether Series meets type assumption. Optionally raises an exception. Does not modify the Series itself.

Parameters:

Name Type Description Default
dtype Type[Any]

The required variable type

required
pass_message str

Message to display if the condition passes.

' ✔️ Assert type passed '
fail_message Union[str, None]

Message to display if the condition fails.

None
raise_exception bool

Whether to raise an exception if the condition fails.

True
exception_to_raise Type[BaseException]

The exception to raise if the condition fails and raise_exception is True.

TypeError
verbose bool

Whether to display the pass message if the condition passes.

False

Returns:

Type Description
Series

The original Series, unchanged.

assert_unique(pass_message=' ✔️ Assert unique passed ', fail_message=' ㄨ Assert unique failed ', raise_exception=True, exception_to_raise=DataError, verbose=False)

Tests whether Series has no duplicate rows. Optionally raises an exception. Does not modify the Series itself.

Args:

pass_message: Message to display if the condition passes.
fail_message: Message to display if the condition fails.
raise_exception: Whether to raise an exception if the condition fails.
exception_to_raise: The exception to raise if the condition fails and raise_exception is True.
verbose: Whether to display the pass message if the condition passes.

Returns:

Type Description
Series

The original Series, unchanged.

describe(fn=lambda s: s, check_name='📏 Distribution', **kwargs)

Displays descriptive statistics about a Series, without modifying the Series itself.

See Pandas docs for describe() for additional usage information, including more configuration options you can pass to this Pandas Checks method.

Parameters:

Name Type Description Default
fn Callable

An optional lambda function to apply to the Series before running Pandas describe(). Example: lambda s: s.dropna().

lambda s: s
check_name Union[str, None]

An optional name for the check to preface the result with.

'📏 Distribution'
**kwargs Any

Optional, additional arguments that are accepted by Pandas describe() method.

{}

Returns:

Type Description
Series

The original Series, unchanged.

disable_checks(enable_asserts=True)

Turns off Pandas Checks globally, such as in production mode. Calls to .check functions will not be run. Does not modify the Series itself.

Args enable_assert: Optionally, whether to also enable or disable assert statements

Returns:

Type Description
Series

The original Series, unchanged.

dtype(fn=lambda s: s, check_name='🗂️ Data type')

Displays the data type of a Series, without modifying the Series itself.

See Pandas docs for .dtype for additional usage information.

Parameters:

Name Type Description Default
fn Callable

An optional lambda function to apply to the Series before running Pandas dtype. Example: lambda s: s.dropna().

lambda s: s
check_name Union[str, None]

An optional name for the check to preface the result with.

'🗂️ Data type'

Returns:

Type Description
Series

The original Series, unchanged.

enable_checks(enable_asserts=True)

Globally enables Pandas Checks. Subequent calls to .check methods will be run. Does not modify the Series itself.

Parameters:

Name Type Description Default
enable_asserts bool

Optionally, whether to globally enable or disable calls to .check.assert_data().

True

Returns:

Type Description
Series

The original Series, unchanged.

function(fn=lambda s: s, check_name=None)

Applies an arbitrary function on a Series and shows the result, without modifying the Series itself.

Example

.check.function(fn=lambda s: s.shape[0]>10, check_name='Has at least 10 rows?') which will result in 'True' or 'False'

Parameters:

Name Type Description Default
fn Callable

The lambda function to apply to the Series. Example: lambda s: s.dropna().

lambda s: s
check_name Union[str, None]

An optional name for the check to preface the result with.

None

Returns:

Type Description
Series

The original Series, unchanged.

get_mode(check_name='⚙️ Pandas Checks mode')

Displays the current values of Pandas Checks global options enable_checks and enable_asserts. Does not modify the Series itself.

Parameters:

Name Type Description Default
check_name Union[str, None]

An optional name for the check. Will be used as a preface the printed result.

'⚙️ Pandas Checks mode'

Returns:

Type Description
Series

The original Series, unchanged.

head(n=5, fn=lambda s: s, check_name=None)

Displays the first n rows of a Series, without modifying the Series itself.

See Pandas docs for head() for additional usage information.

Parameters:

Name Type Description Default
n int

The number of rows to display.

5
fn Callable

An optional lambda function to apply to the Series before running Pandas head(). Example: lambda s: s.dropna().

lambda s: s
check_name Union[str, None]

An optional name for the check, to be printed as preface to the result.

None

Returns:

Type Description
Series

The original Series, unchanged.

hist(fn=lambda s: s, check_name=None, **kwargs)

Displays a histogram for the Series's distribution, without modifying the Series itself.

See Pandas docs for hist() for additional usage information, including more configuration options you can pass to this Pandas Checks method.

Parameters:

Name Type Description Default
fn Callable

An optional lambda function to apply to the Series before running Pandas head(). Example: lambda s: s.dropna().

lambda s: s
check_name Union[str, None]

An optional name for the check, to be printed as preface to the result.

None
**kwargs Any

Optional, additional arguments that are accepted by Pandas hist() method.

{}

Returns:

Type Description
Series

The original Series, unchanged.

Note

Plots are only displayed when code is run in IPython/Jupyter, not in terminal.

info(fn=lambda s: s, check_name='ℹ️ Series info', **kwargs)

Displays summary information about a Series, without modifying the Series itself.

See Pandas docs for info() for additional usage information, including more configuration options you can pass to this Pandas Checks method.

Parameters:

Name Type Description Default
fn Callable

An optional lambda function to apply to the Series before running Pandas info(). Example: lambda s: s.dropna().

lambda s: s
check_name Union[str, None]

An optional name for the check, to be printed as preface to the result.

'ℹ️ Series info'
**kwargs Any

Optional, additional arguments that are accepted by Pandas info() method.

{}

Returns:

Type Description
Series

The original Series, unchanged.

memory_usage(fn=lambda s: s, check_name='💾 Memory usage', **kwargs)

Displays the memory footprint of a Series, without modifying the Series itself.

See Pandas docs for memory_usage() for additional usage information, including more configuration options you can pass to this Pandas Checks method.

Parameters:

Name Type Description Default
fn Callable

An optional lambda function to apply to the Series before running Pandas memory_usage(). Example: lambda s: s.dropna().

lambda s: s
check_name Union[str, None]

An optional name for the check, to be printed as preface to the result.

'💾 Memory usage'
**kwargs Any

Optional, additional arguments that are accepted by Pandas memory_usage() method.

{}

Returns:

Type Description
Series

The original Series, unchanged.

Note

Include argument deep=True to get further memory usage of object dtypes. See Pandas docs for memory_usage() for more info.

ndups(fn=lambda s: s, check_name=None, **kwargs)

Displays the number of duplicated rows in the Series, without modifying the Series itself.

See Pandas docs for duplicated() for additional usage information, including more configuration options you can pass to this Pandas Checks method.

Parameters:

Name Type Description Default
fn Callable

An optional lambda function to apply to the Series before counting the number of duplicates. Example: lambda s: s.dropna().

lambda s: s
check_name Union[str, None]

An optional name for the check, to be printed as preface to the result.

None
**kwargs Any

Optional, additional arguments that are accepted by Pandas duplicated() method.

{}

Returns:

Type Description
Series

The original Series, unchanged.

nnulls(fn=lambda s: s, check_name='👻 Rows with NaNs')

Displays the number of rows with null values in the Series, without modifying the Series itself.

See Pandas docs for isna() for additional usage information.

Parameters:

Name Type Description Default
fn Callable

An optional lambda function to apply to the Series before counting rows with nulls. Example: lambda s: s.dropna().

lambda s: s
check_name Union[str, None]

An optional name for the check, to be printed as preface to the result.

'👻 Rows with NaNs'

Returns:

Type Description
Series

The original Series, unchanged.

nrows(fn=lambda s: s, check_name='☰ Rows')

Displays the number of rows in a Series, without modifying the Series itself.

Parameters:

Name Type Description Default
fn Callable

An optional lambda function to apply to the Series before counting the number of rows. Example: lambda s: s.dropna().

lambda s: s
check_name Union[str, None]

An optional name for the check, to be printed as preface to the result.

'☰ Rows'

Returns:

Type Description
Series

The original Series, unchanged.

nunique(fn=lambda s: s, check_name=None, **kwargs)

Displays the number of unique rows in a Series, without modifying the Series itself.

See Pandas docs for nunique() for additional usage information, including more configuration options you can pass to this Pandas Checks method.

Parameters:

Name Type Description Default
fn Callable

An optional lambda function to apply to the Series before running Pandas nunique(). Example: lambda s: s.dropna().

lambda s: s
check_name Union[str, None]

An optional name for the check, to be printed as preface to the result.

None
**kwargs Any

Optional, additional arguments that are accepted by Pandas nunique() method.

{}

Returns:

Type Description
Series

The original Series, unchanged.

plot(fn=lambda s: s, check_name='', **kwargs)

Displays a plot of the Series, without modifying the Series itself.

See Pandas docs for plot() for additional usage information, including more configuration options you can pass to this Pandas Checks method.

Parameters:

Name Type Description Default
fn Callable

An optional lambda function to apply to the Series before running Pandas plot(). Example: lambda s: s.dropna().

lambda s: s
check_name Union[str, None]

An optional title for the plot.

''
**kwargs Any

Optional, additional arguments that are accepted by Pandas plot() method.

{}

Returns:

Type Description
Series

The original Series, unchanged.

Note

Plots are only displayed when code is run in IPython/Jupyter, not in terminal.

If you pass a 'title' kwarg, it becomes the plot title, overriding check_name

print(object=None, fn=lambda s: s, check_name=None, max_rows=10)

Displays text, another object, or (by default) the current DataFrame's head. Does not modify the Series itself.

Parameters:

Name Type Description Default
object Any

Object to print. Can be anything printable: str, int, list, another DataFrame, etc. If None, print the Series's head (with max_rows rows).

None
fn Callable

An optional lambda function to apply to the Series before printing object. Example: lambda s: s.dropna().

lambda s: s
check_name Union[str, None]

An optional name for the check, to be printed as preface to the result.

None
max_rows int

Maximum number of rows to print if object=None.

10

Returns:

Type Description
Series

The original Series, unchanged.

print_time_elapsed(start_time, lead_in='Time elapsed', units='auto')

Displays the time elapsed since start_time.

Args: start_time: The index time when the stopwatch started, which comes from the Pandas Checks start_timer() lead_in: Optional text to print before the elapsed time. units: The units in which to display the elapsed time. Allowed values: "auto", "milliseconds", "seconds", "minutes", "hours" or shorthands "ms", "s", "m", "h".

Raises:

Type Description
ValueError

If units is not one of allowed values.

Returns:

Type Description
Series

The original Series, unchanged.

reset_format()

Globally restores all Pandas Checks formatting options to their default "factory" settings. Does not modify the Series itself.

Returns:

Type Description
Series

The original Series, unchanged.

set_format(**kwargs)

Configures selected formatting options for Pandas Checks. Run pandas_checks.describe_options() to see a list of available options. Does not modify the Series itself

For example, .check.set_format(check_text_tag= "h1", use_emojis=False`) will globally change Pandas Checks to display text results as H1 headings and remove all emojis.

Parameters:

Name Type Description Default
**kwargs Any

Pairs of setting name and its new value.

{}

Returns:

Type Description
Series

The original Series, unchanged.

set_mode(enable_checks, enable_asserts)

Configures the operation mode for Pandas Checks globally. Does not modify the Series itself.

Parameters:

Name Type Description Default
enable_checks bool

Whether to run any Pandas Checks methods globally. Does not affect .check.assert_data().

required
enable_asserts bool

Whether to run calls to Pandas Checks .check.assert_data() globally.

required

Returns:

Type Description
Series

The original Series, unchanged.

shape(fn=lambda s: s, check_name='📐 Shape')

Displays the Series's dimensions, without modifying the Series itself.

See Pandas docs for shape for additional usage information.

Parameters:

Name Type Description Default
fn Callable

An optional lambda function to apply to the Series before running Pandas shape. Example: lambda s: s.dropna().

lambda s: s
check_name Union[str, None]

An optional name for the check, to be printed as preface to the result.

'📐 Shape'

Returns:

Type Description
Series

The original Series, unchanged.

Note

See also .check.nrows()

tail(n=5, fn=lambda s: s, check_name=None)

Displays the last n rows of the Series, without modifying the Series itself.

See Pandas docs for tail() for additional usage information.

Parameters:

Name Type Description Default
n int

Number of rows to show.

5
fn Callable

An optional lambda function to apply to the Series before running Pandas tail(). Example: lambda s: s.dropna().

lambda s: s
check_name Union[str, None]

An optional name for the check, to be printed as preface to the result.

None

Returns:

Type Description
Series

The original Series, unchanged.

unique(fn=lambda s: s, check_name=None)

Displays the unique values in a Series, without modifying the Series itself.

See Pandas docs for unique() for additional usage information.

Parameters:

Name Type Description Default
fn Callable

An optional lambda function to apply to the Series before running Pandas unique(). Example: lambda s: s.dropna().

lambda s: s
check_name Union[str, None]

An optional name for the check, to be printed as preface to the result.

None

Returns:

Type Description
Series

The original Series, unchanged.

value_counts(fn=lambda s: s, max_rows=10, check_name=None, **kwargs)

Displays the value counts for a Series, without modifying the Series itself.

See Pandas docs for value_counts() for additional usage information, including more configuration options you can pass to this Pandas Checks method.

Parameters:

Name Type Description Default
max_rows int

Maximum number of rows to show in the value counts.

10
fn Callable

An optional lambda function to apply to the Series before running Pandas value_counts(). Example: lambda s: s.dropna().

lambda s: s
check_name Union[str, None]

An optional name for the check, to be printed as preface to the result.

None
**kwargs Any

Optional, additional arguments that are accepted by Pandas value_counts() method.

{}

Returns:

Type Description
Series

The original Series, unchanged.

write(path, format=None, fn=lambda s: s, verbose=False, **kwargs)

Exports Series to file, without modifying the Series itself.

Format is inferred from path extension like .csv.

This functions uses the corresponding Pandas export function such as to_csv(). See Pandas docs for those functions for additional usage information, including more configuration options you can pass to this Pandas Checks method.

Parameters:

Name Type Description Default
path str

Path to write the file to.

required
format Union[str, None]

Optional file format to force for the export. If None, format is inferred from the file's extension in path.

None
fn Callable

An optional lambda function to apply to the Series before exporting. Example: lambda s: s.dropna().

lambda s: s
verbose bool

Whether to print a message when the file is written.

False
**kwargs Any

Optional, additional keyword arguments to pass to the Pandas export function (.to_csv).

{}

Returns:

Type Description
Series

The original Series, unchanged.

Note

Exporting to some formats such as Excel, Feather, and Parquet may require you to install additional packages.