{"record":{"id":"ec18d0e316331086","repo":"pandas-dev/pandas","slug":"datetimelike-compat-true-left-values-is-not-e","errorCode":null,"errorMessage":"[datetimelike_compat=True] {left._values} is not equal to {right._values}.","messagePattern":"\\[datetimelike_compat=True\\] (.+?) is not equal to (.+?)\\.","errorType":"exception","errorClass":"AssertionError","httpStatus":null,"severity":"error","filePath":"pandas/_testing/asserters.py","lineNumber":1207,"sourceCode":"                obj=str(obj),\n                class_obj=f\"{obj} values\",\n                index_values=left.index,\n            )\n    elif check_datetimelike_compat and (\n        needs_i8_conversion(left.dtype) or needs_i8_conversion(right.dtype)\n    ):\n        # we want to check only if we have compat dtypes\n        # e.g. integer and M|m are NOT compat, but we can simply check\n        # the values in that case\n\n        # datetimelike may have different objects (e.g. datetime.datetime\n        # vs Timestamp) but will compare equal\n        if not Index(left._values).equals(Index(right._values)):\n            msg = (\n                f\"[datetimelike_compat=True] {left._values} \"\n                f\"is not equal to {right._values}.\"\n            )\n            raise AssertionError(msg)\n    elif isinstance(left.dtype, IntervalDtype) and isinstance(\n        right.dtype, IntervalDtype\n    ):\n        assert_interval_array_equal(\n            cast(\"IntervalArray\", left.array), cast(\"IntervalArray\", right.array)\n        )\n    elif isinstance(left.dtype, CategoricalDtype) or isinstance(\n        right.dtype, CategoricalDtype\n    ):\n        _testing.assert_almost_equal(\n            left._values,\n            right._values,\n            rtol=rtol,\n            atol=atol,\n            check_dtype=bool(check_dtype),\n            obj=str(obj),\n            index_values=left.index,\n        )","sourceCodeStart":1189,"sourceCodeEnd":1225,"githubUrl":"https://github.com/pandas-dev/pandas/blob/3b7651241d4da534b3559b60ef128e1c34f54116/pandas/_testing/asserters.py#L1189-L1225","documentation":"Raised inside `assert_series_equal` when `datetimelike_compat=True` is set and the underlying values of two Series (with compatible but not identical dtypes — e.g. datetime64 vs period, or M8 vs object of datetimes) are not equal under Index equality. The compat flag is an internal escape hatch for comparing Series whose dtypes are 'compatible' (datetime-like) but represented differently.","triggerScenarios":"Internal pandas tests calling `assert_series_equal` with `datetimelike_compat=True` on Series where one side holds `datetime.datetime` objects and the other holds `Timestamp`s that don't compare equal after coercion; mismatches surfaced during dtype refactors.","commonSituations":"Refactoring datetimelike dtype representations; comparing Series produced by different I/O paths (one as object, one as datetime64).","solutions":["Normalize both Series to the same dtype before asserting (`s.astype('datetime64[ns]')`).","Drop `datetimelike_compat=True` if not needed and compare values directly.","Inspect `left._values` vs `right._values` to find the offending element."],"exampleFix":"// before\nassert_series_equal(s_obj, s_dt, datetimelike_compat=True)\n\n// after\nassert_series_equal(s_obj.astype('datetime64[ns]'), s_dt)","handlingStrategy":"validation","validationCode":"if datetimelike_compat:\n    assert Index(left._values).equals(Index(right._values))","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Normalize both Series to the same dtype before comparing.","Reserve datetimelike_compat for pandas-internal dtype tests."],"tags":["testing","datetime","dtype-compat"],"backgroundTag":null,"analyzedSha":"3b7651241d4da534b3559b60ef128e1c34f54116","analyzedAt":"2026-08-11T22:10:44.015Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}