File tree Expand file tree Collapse file tree 1 file changed +12
-3
lines changed Expand file tree Collapse file tree 1 file changed +12
-3
lines changed Original file line number Diff line number Diff line change @@ -524,9 +524,8 @@ def test_setitem_boolean(self):
524
524
values [values == 2 ] = 3
525
525
assert_almost_equal (df .values , values )
526
526
527
- with tm .assert_raises_regex (TypeError , 'Must pass '
528
- 'DataFrame with '
529
- 'boolean values only' ):
527
+ msg = "Must pass DataFrame or 2-d ndarray with boolean values only"
528
+ with tm .assert_raises_regex (TypeError , msg ):
530
529
df [df * 0 ] = 2
531
530
532
531
# index with DataFrame
@@ -542,6 +541,16 @@ def test_setitem_boolean(self):
542
541
np .putmask (expected .values , mask .values , df .values * 2 )
543
542
assert_frame_equal (df , expected )
544
543
544
+ def test_setitem_boolean_ndarary (self ):
545
+ df = self .frame .copy ()
546
+ mask = df > np .abs (df )
547
+ expected = df .copy ()
548
+ expected .values [mask .values ] = nan
549
+ # index with 2-d boolean ndarray
550
+ actual = df .copy ()
551
+ actual [mask .values ] = nan
552
+ assert_frame_equal (actual , expected )
553
+
545
554
def test_setitem_cast (self ):
546
555
self .frame ['D' ] = self .frame ['D' ].astype ('i8' )
547
556
assert self .frame ['D' ].dtype == np .int64
You can’t perform that action at this time.
0 commit comments