{"record":{"id":"b9d252d95b8b02ab","repo":"pola-rs/polars","slug":"objects-are-equal-but-are-expected-not-to-be","errorCode":null,"errorMessage":"{objects} are equal (but are expected not to be)","messagePattern":"(.+?) are equal \\(but are expected not to be\\)","errorType":"exception","errorClass":"AssertionError","httpStatus":null,"severity":"error","filePath":"py-polars/src/polars/testing/asserts/frame.py","lineNumber":240,"sourceCode":"    lazy = _assert_correct_input_type(left, right)\n    try:\n        assert_frame_equal(\n            left=left,\n            right=right,\n            check_column_order=check_column_order,\n            check_row_order=check_row_order,\n            check_dtypes=check_dtypes,\n            check_exact=check_exact,\n            rel_tol=rel_tol,\n            abs_tol=abs_tol,\n            categorical_as_str=categorical_as_str,\n        )\n    except AssertionError:\n        return\n    else:\n        objects = \"LazyFrames\" if lazy else \"DataFrames\"\n        msg = f\"{objects} are equal (but are expected not to be)\"\n        raise AssertionError(msg)\n","sourceCodeStart":222,"sourceCodeEnd":241,"githubUrl":"https://github.com/pola-rs/polars/blob/fe841f959ef4d2ceefc05a310d33ed7b1ab24e5e/py-polars/src/polars/testing/asserts/frame.py#L222-L241","documentation":"assert_frame_not_equal first runs assert_frame_equal; if equality succeeds (no AssertionError), the frames ARE equal, so the not-equal assertion fails with this message. It confirms your expectation of difference was wrong.","triggerScenarios":"Calling assert_frame_not_equal(df1, df2) where the two frames compare identical, including when both are empty LazyFrames or the only intended difference is ignored by the equality options.","commonSituations":"Testing that a transformation changed data but the transformation is a no-op (e.g. cache bug tests like cspe nondeterminism cases); comparing delta-scanned versions of an unchanged table; forgetting check_dtype/column_order flags that mask real differences.","solutions":["Inspect both frames (df1.equals(df2), print) to confirm a real difference exists.","Fix the transformation under test so it actually alters the data.","If difference is only in dtypes/order you do care about, pass check_dtypes=False / check_column_order=False so equality logic matches intent — but only when the intent is genuinely 'not equal under these criteria'."],"exampleFix":"# before\ndf2 = df.with_columns(pl.lit(1).alias('x'))\ndf2 = df2.drop('x')  # no-op net effect -> frames equal\nassert_frame_not_equal(df, df2)  # AssertionError\n\n# after\ndf2 = df.with_columns(pl.col('x') + 1)\nassert_frame_not_equal(df, df2)","handlingStrategy":"validation","validationCode":"assert not df1.equals(df2), \"precondition: frames must differ before assert_frame_not_equal\"","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Print or diff both frames when a not-equal assertion fails","Ensure the transformation under test has an observable effect","Be deliberate about check_dtypes/check_column_order flags vs actual test intent"],"tags":["polars","testing","assertion","frame-equality"],"backgroundTag":"unexpected-equal-values","analyzedSha":"fe841f959ef4d2ceefc05a310d33ed7b1ab24e5e","analyzedAt":"2026-09-18T22:14:11.667Z","contentChangedAt":"2026-09-18T22:14:11.667Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}