{"record":{"id":"34b49ab37ad8de7c","repo":"pandas-dev/pandas","slug":"obj-are-different-message","errorCode":null,"errorMessage":"{obj} are different\n\n{message}","messagePattern":"(.+?) are different\n\n(.+?)","errorType":"exception","errorClass":"AssertionError","httpStatus":null,"severity":"error","filePath":"pandas/_testing/asserters.py","lineNumber":735,"sourceCode":"    elif isinstance(left, (CategoricalDtype, StringDtype, NumpyEADtype)):\n        left = repr(left)\n\n    if isinstance(right, np.ndarray):\n        right = pprint_thing(right)\n    elif isinstance(right, (CategoricalDtype, StringDtype, NumpyEADtype)):\n        right = repr(right)\n\n    msg += f\"\"\"\n[left]:  {left}\n[right]: {right}\"\"\"\n\n    if diff is not None:\n        msg += f\"\\n[diff]: {diff}\"\n\n    if first_diff is not None:\n        msg += f\"\\n{first_diff}\"\n\n    raise AssertionError(msg)\n\n\ndef assert_numpy_array_equal(\n    left: Any,\n    right: Any,\n    strict_nan: bool = False,\n    check_dtype: bool | Literal[\"equiv\"] = True,\n    err_msg: str | None = None,\n    check_same: Literal[\"copy\", \"same\"] | None = None,\n    obj: str = \"numpy array\",\n    index_values: Index | np.ndarray | None = None,\n    *,\n    class_obj: str | None = None,\n) -> None:\n    \"\"\"\n    Check that 'np.ndarray' is equivalent.\n\n    Parameters","sourceCodeStart":717,"sourceCodeEnd":753,"githubUrl":"https://github.com/pandas-dev/pandas/blob/71959b8cb9b2459c16e14b34f28b178ccfe14735/pandas/_testing/asserters.py#L717-L753","documentation":"raise_assert_detail (asserters.py:694-735) is the central failure-reporting function for pandas.testing assertions. It assembles a structured message — object name, what differs, [index], [left], [right], optional [diff] and first-diff — and raises AssertionError. It is the body you see when assert_index_equal, assert_series_equal, assert_frame_equal, assert_numpy_array_equal, or assert_extension_array_equal find an actual inequality.","triggerScenarios":"Two pandas objects that are genuinely unequal: differing values, differing shapes/lengths, differing dtype when check_dtype=True, differing names when check_names=True, or differing categorical categories. raise_assert_detail is invoked from inside the assert_*_equal functions after a comparison fails, so hitting it means a real test failure.","commonSituations":"Float comparisons without rtol/atol; dtype drift (int32 vs int64); timezone-naive vs timezone-aware datetimes; index alignment differences; categorical category ordering; the expected fixture was updated but not the assertion.","solutions":["Read the [left]/[right]/[diff] blocks in the message to locate the first divergence.","If the difference is floating-point noise, pass check_dtype=False and use rtol/atol (or check_exact=False).","If index/names differ, set check_names=False or check_index=False only if intentionally skipping that check.","Fix the data or the expected fixture so the objects truly match."],"exampleFix":"# before — fails on float dtype/values\nassert_series_equal(pd.Series([1.0]), pd.Series([1.000001]))\n\n# after\nassert_series_equal(pd.Series([1.0]), pd.Series([1.000001]), check_exact=False, rtol=1e-4)","handlingStrategy":"validation","validationCode":"# Decide on exactness/tolerance before asserting\nimport numpy as np\nif left.dtype.kind in 'iu' and right.dtype.kind in 'iu':\n    check_exact = True\nelse:\n    check_exact = False  # use rtol/atol for floats","typeGuard":null,"tryCatchPattern":"try:\n    assert_series_equal(left, right, check_exact=False, rtol=1e-5, atol=1e-8)\nexcept AssertionError as e:\n    # log the structured diff for diagnosis\n    raise","preventionTips":["For float data always pass check_exact=False with explicit rtol/atol.","Set check_dtype=False when dtype precision (int32/int64) is not material.","Align timezones and normalize dtypes on both sides before comparing."],"tags":["testing","assertion","equality","diff","assertionerror"],"analyzedSha":"71959b8cb9b2459c16e14b34f28b178ccfe14735","analyzedAt":"2026-08-07T01:30:20.476Z","schemaVersion":2},"datasetVersion":"2026-08-07T03:17:09.362Z"}