@@ -8660,6 +8660,33 @@ def test_boolean_indexing(self):
8660
8660
df1 [df1 > 2.0 * df2 ] = - 1
8661
8661
assert_frame_equal (df1 , expected )
8662
8662
8663
+ def test_boolean_indexing_mixed (self ):
8664
+ df = DataFrame (
8665
+ {0L : {35 : np .nan , 40 : np .nan , 43 : np .nan , 49 : np .nan , 50 : np .nan },
8666
+ 1L : {35 : np .nan ,
8667
+ 40 : 0.32632316859446198 ,
8668
+ 43 : np .nan ,
8669
+ 49 : 0.32632316859446198 ,
8670
+ 50 : 0.39114724480578139 },
8671
+ 2L : {35 : np .nan , 40 : np .nan , 43 : 0.29012581014105987 , 49 : np .nan , 50 : np .nan },
8672
+ 3L : {35 : np .nan , 40 : np .nan , 43 : np .nan , 49 : np .nan , 50 : np .nan },
8673
+ 4L : {35 : 0.34215328467153283 , 40 : np .nan , 43 : np .nan , 49 : np .nan , 50 : np .nan },
8674
+ 'y' : {35 : 0 , 40 : 0 , 43 : 0 , 49 : 0 , 50 : 1 }})
8675
+
8676
+ # mixed int/float ok
8677
+ df2 = df .copy ()
8678
+ df2 [df2 > 0.3 ] = 1
8679
+ expected = df .copy ()
8680
+ expected .loc [40 ,1 ] = 1
8681
+ expected .loc [49 ,1 ] = 1
8682
+ expected .loc [50 ,1 ] = 1
8683
+ expected .loc [35 ,4 ] = 1
8684
+ assert_frame_equal (df2 ,expected )
8685
+
8686
+ # add object, should this raise?
8687
+ df ['foo' ] = 'test'
8688
+ self .assertRaises (ValueError , df .__setitem__ , df > 0.3 , 1 )
8689
+
8663
8690
def test_sum_bools (self ):
8664
8691
df = DataFrame (index = range (1 ), columns = range (10 ))
8665
8692
bools = isnull (df )
0 commit comments