pandas-dev/pandas · error · ValueError

check_like must be False if check_index is False

Error message

check_like must be False if check_index is False

What it means

Raised by `assert_series_equal` when the caller passes `check_index=False` together with `check_like=True`. These are contradictory: `check_like=True` means 'ignore order by reindexing right onto left' (which inherently operates on the index), while `check_index=False` means 'do not compare the index at all'. pandas refuses the combination with a ValueError rather than silently picking a behavior.

Solutions

  1. If you genuinely want to ignore order, keep `check_like=True` and remove `check_index=False`.
  2. If you want to skip index comparison, set `check_like=False` (or omit) and keep `check_index=False`.
  3. Audit wrapper helpers for conflicting defaults.

Example fix

// before
assert_series_equal(a, b, check_index=False, check_like=True)

// after
assert_series_equal(a, b, check_index=False)
Defensive patterns

Strategy: validation

Validate before calling

assert not (check_index is False and check_like is True), 'check_like requires check_index'

Prevention

When it happens

Trigger: Calling `pd.testing.assert_series_equal(a, b, check_index=False, check_like=True)`; passing kwargs through a wrapper that defaults `check_like=True` while a user sets `check_index=False`.

Common situations: Layered test helpers that merge conflicting defaults; copy-paste of assert kwargs across tests; migration from older pandas where this combination was silently permitted.

Related errors


AI-assisted analysis of pandas-dev/pandas@3b7651241d (2026-08-11). Data as JSON: /api/errors/3ca10c35cef7500f. Report an issue: GitHub.

Appendix: source

Thrown at pandas/_testing/asserters.py:1116

        right_index_dtypes = (
            [right.index.dtype]
            if right.index.nlevels == 1
            else cast("MultiIndex", right.index).dtypes
        )
        check_exact_index = all(
            dtype.kind in "iu" for dtype in left_index_dtypes
        ) or all(dtype.kind in "iu" for dtype in right_index_dtypes)
    elif check_exact is lib.no_default:
        check_exact = False
        check_exact_index = False
    else:
        check_exact_index = check_exact

    rtol = rtol if rtol is not lib.no_default else 1.0e-5
    atol = atol if atol is not lib.no_default else 1.0e-8

    if not check_index and check_like:
        raise ValueError("check_like must be False if check_index is False")

    # instance validation
    _check_isinstance(left, right, Series)

    if check_series_type:
        assert_class_equal(left, right, obj=obj)

    # length comparison
    if len(left) != len(right):
        msg1 = f"{len(left)}, {left.index}"
        msg2 = f"{len(right)}, {right.index}"
        raise_assert_detail(obj, "Series length are different", msg1, msg2)

    if check_flags:
        assert left.flags == right.flags, f"{left.flags!r} != {right.flags!r}"

    if check_index:
        # GH #38183

View on GitHub (pinned to 3b7651241d)