@@ -1631,12 +1631,12 @@ def highlight_null(
1631
1631
-------
1632
1632
self : Styler
1633
1633
"""
1634
+
1635
+ def f (data : DataFrame , props : str ) -> np .ndarray :
1636
+ return np .where (pd .isna (data ).values , props , "" )
1637
+
1634
1638
return self .apply (
1635
- _Builtins ._highlight_func ,
1636
- axis = None ,
1637
- subset = subset ,
1638
- props = f"background-color: { null_color } ;" ,
1639
- highlight = "null" ,
1639
+ f , axis = None , subset = subset , props = f"background-color: { null_color } ;"
1640
1640
)
1641
1641
1642
1642
def highlight_max (
@@ -1662,12 +1662,12 @@ def highlight_max(
1662
1662
-------
1663
1663
self : Styler
1664
1664
"""
1665
+
1666
+ def f (data : FrameOrSeries , props : str ) -> np .ndarray :
1667
+ return np .where (data == np .nanmax (data .values ), props , "" )
1668
+
1665
1669
return self .apply (
1666
- _Builtins ._highlight_func ,
1667
- axis = axis ,
1668
- subset = subset ,
1669
- props = f"background-color: { color } ;" ,
1670
- highlight = "max" ,
1670
+ f , axis = axis , subset = subset , props = f"background-color: { color } ;"
1671
1671
)
1672
1672
1673
1673
def highlight_min (
@@ -1693,12 +1693,12 @@ def highlight_min(
1693
1693
-------
1694
1694
self : Styler
1695
1695
"""
1696
+
1697
+ def f (data : FrameOrSeries , props : str ) -> np .ndarray :
1698
+ return np .where (data == np .nanmin (data .values ), props , "" )
1699
+
1696
1700
return self .apply (
1697
- _Builtins ._highlight_func ,
1698
- axis = axis ,
1699
- subset = subset ,
1700
- props = f"background-color: { color } ;" ,
1701
- highlight = "min" ,
1701
+ f , axis = axis , subset = subset , props = f"background-color: { color } ;"
1702
1702
)
1703
1703
1704
1704
@classmethod
@@ -1803,27 +1803,6 @@ def pipe(self, func: Callable, *args, **kwargs):
1803
1803
return com .pipe (self , func , * args , ** kwargs )
1804
1804
1805
1805
1806
- class _Builtins :
1807
- @staticmethod
1808
- def _highlight_func (
1809
- data : FrameOrSeries ,
1810
- props : str = "background-color: yellow;" ,
1811
- highlight : str = "max" ,
1812
- ** kwargs ,
1813
- ) -> np .ndarray :
1814
- """
1815
- Highlight the value in a Series or DataFrame by func with css-properties
1816
- """
1817
- if highlight == "max" :
1818
- return np .where (data == np .nanmax (data .values ), props , "" )
1819
- elif highlight == "min" :
1820
- return np .where (data == np .nanmin (data .values ), props , "" )
1821
- elif highlight == "null" :
1822
- return np .where (pd .isna (data ).values , props , "" )
1823
- else :
1824
- raise ValueError ("'highlight' must one of 'max', 'min', 'null'" )
1825
-
1826
-
1827
1806
class _Tooltips :
1828
1807
"""
1829
1808
An extension to ``Styler`` that allows for and manipulates tooltips on hover
0 commit comments