From 900f3b1070e0b0b533efcd5eb92d6e03f56ca6d9 Mon Sep 17 00:00:00 2001 From: parkjaewon Date: Fri, 22 Nov 2024 09:12:19 +0900 Subject: [PATCH] BUG (string dtype): comparison of string column to mixed object column fails #60228 --- pandas/tests/series/methods/test_compare.py | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/pandas/tests/series/methods/test_compare.py b/pandas/tests/series/methods/test_compare.py index 2a57d5139b62c..74d2e35eaf502 100644 --- a/pandas/tests/series/methods/test_compare.py +++ b/pandas/tests/series/methods/test_compare.py @@ -138,3 +138,15 @@ def test_compare_datetime64_and_string(): tm.assert_series_equal(result_eq1, expected_eq) tm.assert_series_equal(result_eq2, expected_eq) tm.assert_series_equal(result_neq, expected_neq) + +def test_comparison_string_mixed_object(): + pd.options.future.infer_string = True + + ser_string = pd.Series(["a", "b"], dtype="string") + ser_mixed = pd.Series([1, "b"]) + + result = ser_string == ser_mixed + expected = pd.Series([False, True], dtype="boolean") + tm.assert_series_equal(result, expected) + + pd.options.future.infer_string = False \ No newline at end of file