@@ -610,6 +610,22 @@ def test_index_contains(self, index, val):
610
610
def test_index_not_contains (self , index , val ):
611
611
assert val not in index
612
612
613
+ @pytest .mark .parametrize ("index,val" , [
614
+ (Index ([0 , 1 , '2' ]), 0 ),
615
+ (Index ([0 , 1 , '2' ]), '2' ),
616
+ ])
617
+ def test_mixed_index_contains (self , index , val ):
618
+ # GH 19860
619
+ assert val in index
620
+
621
+ @pytest .mark .parametrize ("index,val" , [
622
+ (Index ([0 , 1 , '2' ]), '1' ),
623
+ (Index ([0 , 1 , '2' ]), 2 ),
624
+ ])
625
+ def test_mixed_index_not_contains (self , index , val ):
626
+ # GH 19860
627
+ assert val not in index
628
+
613
629
def test_index_type_coercion (self ):
614
630
615
631
with catch_warnings (record = True ):
@@ -710,6 +726,22 @@ def test_float_index_at_iat(self):
710
726
for i in range (len (s )):
711
727
assert s .iat [i ] == i + 1
712
728
729
+ def test_mixed_index_assignment (self ):
730
+ # GH 19860
731
+ s = Series ([1 , 2 , 3 , 4 , 5 ], index = ['a' , 'b' , 'c' , 1 , 2 ])
732
+ s .at ['a' ] = 11
733
+ assert s .iat [0 ] == 11
734
+ s .at [1 ] = 22
735
+ assert s .iat [3 ] == 22
736
+
737
+ def test_mixed_index_no_fallback (self ):
738
+ # GH 19860
739
+ s = Series ([1 , 2 , 3 , 4 , 5 ], index = ['a' , 'b' , 'c' , 1 , 2 ])
740
+ with pytest .raises (KeyError ):
741
+ s .at [0 ]
742
+ with pytest .raises (KeyError ):
743
+ s .at [4 ]
744
+
713
745
def test_rhs_alignment (self ):
714
746
# GH8258, tests that both rows & columns are aligned to what is
715
747
# assigned to. covers both uniform data-type & multi-type cases
0 commit comments