@@ -541,7 +541,8 @@ def f(x):
541
541
542
542
style1 = "foo: bar"
543
543
544
- result = self .df .style .where (f , style1 )._compute ().ctx
544
+ with tm .assert_produces_warning (FutureWarning ):
545
+ result = self .df .style .where (f , style1 )._compute ().ctx
545
546
expected = {
546
547
(r , c ): [("foo" , "bar" )]
547
548
for r , row in enumerate (self .df .index )
@@ -568,14 +569,15 @@ def f(x):
568
569
style1 = "foo: bar"
569
570
style2 = "baz: foo"
570
571
571
- result = self .df .style .where (f , style1 , style2 , subset = slice_ )._compute ().ctx
572
+ with tm .assert_produces_warning (FutureWarning ):
573
+ res = self .df .style .where (f , style1 , style2 , subset = slice_ )._compute ().ctx
572
574
expected = {
573
575
(r , c ): [("foo" , "bar" ) if f (self .df .loc [row , col ]) else ("baz" , "foo" )]
574
576
for r , row in enumerate (self .df .index )
575
577
for c , col in enumerate (self .df .columns )
576
578
if row in self .df .loc [slice_ ].index and col in self .df .loc [slice_ ].columns
577
579
}
578
- assert result == expected
580
+ assert res == expected
579
581
580
582
def test_where_subset_compare_with_applymap (self ):
581
583
# GH 17474
@@ -597,9 +599,10 @@ def g(x):
597
599
]
598
600
599
601
for slice_ in slices :
600
- result = (
601
- self .df .style .where (f , style1 , style2 , subset = slice_ )._compute ().ctx
602
- )
602
+ with tm .assert_produces_warning (FutureWarning ):
603
+ result = (
604
+ self .df .style .where (f , style1 , style2 , subset = slice_ )._compute ().ctx
605
+ )
603
606
expected = self .df .style .applymap (g , subset = slice_ )._compute ().ctx
604
607
assert result == expected
605
608
@@ -609,14 +612,15 @@ def test_where_kwargs(self):
609
612
def f (x , val ):
610
613
return x > val
611
614
612
- result = df .style .where (f , "color:green;" , "color:red;" , val = 2 )._compute ().ctx
615
+ with tm .assert_produces_warning (FutureWarning ):
616
+ res = df .style .where (f , "color:green;" , "color:red;" , val = 2 )._compute ().ctx
613
617
expected = {
614
618
(0 , 0 ): [("color" , "red" )],
615
619
(0 , 1 ): [("color" , "red" )],
616
620
(1 , 0 ): [("color" , "green" )],
617
621
(1 , 1 ): [("color" , "green" )],
618
622
}
619
- assert result == expected
623
+ assert res == expected
620
624
621
625
def test_empty (self ):
622
626
df = DataFrame ({"A" : [1 , 0 ]})
0 commit comments