@@ -1717,3 +1717,34 @@ def test_is_monotonic_pyarrow_list_type():
17171717 idx = Index ([[1 ], [2 , 3 ]], dtype = pd .ArrowDtype (pa .list_ (pa .int64 ())))
17181718 assert not idx .is_monotonic_increasing
17191719 assert not idx .is_monotonic_decreasing
1720+
1721+ def test_index_equals_string_vs_object ():
1722+ # GH 61099
1723+ idx1 = pd .Index (['a' , 'b' , 'c' ])
1724+ idx2 = pd .Index (['a' , 'b' , 'c' ], dtype = 'string' )
1725+ assert idx1 .equals (idx2 )
1726+ assert idx2 .equals (idx1 )
1727+
1728+ def test_compare_string_vs_object_index_equality ():
1729+ # GH 61099
1730+ s1 = pd .Series ([1 , 2 , 3 ], index = ['a' , 'b' , 'c' ]) # dtype=object
1731+ s2 = pd .Series ([0 , 1 , 2 ], index = pd .Index (['a' , 'b' , 'c' ], dtype = 'string' )) # dtype=string
1732+ result = s1 > s2
1733+ expected = pd .Series ([True , True , True ], index = ['a' , 'b' , 'c' ])
1734+ pd .testing .assert_series_equal (result , expected )
1735+
1736+ def test_align_string_vs_object_index ():
1737+ # GH 61099
1738+ s1 = pd .Series ([1 , 2 , 3 ], index = ['a' , 'b' , 'c' ]) # object
1739+ s2 = pd .Series ([1 , 2 , 3 ], index = pd .Index (['a' , 'b' , 'c' ], dtype = 'string' )) # string
1740+ s1_aligned , s2_aligned = s1 .align (s2 )
1741+ assert list (s1_aligned .index ) == list (s2_aligned .index )
1742+
1743+ def test_comparison_without_manual_casting ():
1744+ # GH 61099
1745+ s1 = pd .Series ([1 , 2 , 3 ], index = ['a' , 'b' , 'c' ]) # object index
1746+ s2 = pd .Series ([1 , 2 , 3 ], index = pd .Index (['a' , 'b' , 'c' ], dtype = 'string' ))
1747+ # Should not raise
1748+ result = s1 == s2
1749+ expected = pd .Series ([True , True , True ], index = ['a' , 'b' , 'c' ])
1750+ pd .testing .assert_series_equal (result , expected )
0 commit comments