pandas.testing.assert_series_equal

pandas 3.1.1 · Testing, errors, and warnings · function

Compare two Series in a test, including their values, labels and configured metadata checks.

Call syntax

pd.testing.assert_series_equal(…) Full signature
pd.testing.assert_series_equal(
    left,
    right,
    check_dtype=True,
    check_index_type='equiv',
    check_series_type=True,
    check_names=True,
    check_exact=…,
    check_datetimelike_compat=False,
    check_categorical=True,
    check_category_order=True,
    check_freq=…,
    check_flags=True,
    rtol=…,
    atol=…,
    obj='Series',
    *,
    check_index=True,
    check_like=False,
)

Run the example

Edit the example and select Run Python to see the result.

Parameters

ParameterRequirementAccepted values and behavior
left Required
Positional or keyword
Series

Supply the left-hand input or the left endpoint of the interval.

right Required
Positional or keyword
Series

Supply the right-hand input or the right endpoint of the interval.

check_dtype Optional
Positional or keyword
Default True
bool

Choose whether a test requires the two dtypes to match.

check_index_type Optional
Positional or keyword
Default 'equiv'
bool or {'equiv'}
check_series_type Optional
Positional or keyword
Default True
bool
check_names Optional
Positional or keyword
Default True
bool

Choose whether a test compares index, column, or Series names.

check_exact Optional
Positional or keyword
bool

Choose whether numeric equality tests require exact values.

check_datetimelike_compat Optional
Positional or keyword
Default False
bool
check_categorical Optional
Positional or keyword
Default True
bool

Choose whether a test compares categorical internals.

check_category_order Optional
Positional or keyword
Default True
bool
check_freq Optional
Positional or keyword
bool

Choose whether a test compares frequency metadata.

check_flags Optional
Positional or keyword
Default True
bool
rtol Optional
Positional or keyword
float

Set the acceptable relative difference in a numeric equality check.

atol Optional
Positional or keyword
float

Set the acceptable absolute difference in a numeric equality check.

obj Optional
Positional or keyword
Default 'Series'
str

Provide the pandas object, scalar, or array-like input described in the accepted values.

check_index Optional
Keyword only
Default True
bool
check_like Optional
Keyword only
Default False
bool

Returns

None when the checks pass. Raises AssertionError when they fail.