Skip to content

Commit 4fdaaed

Browse files
committed
req changes
1 parent 59baa71 commit 4fdaaed

File tree

1 file changed

+15
-36
lines changed

1 file changed

+15
-36
lines changed

pandas/io/formats/style.py

Lines changed: 15 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -1631,12 +1631,12 @@ def highlight_null(
16311631
-------
16321632
self : Styler
16331633
"""
1634+
1635+
def f(data: DataFrame, props: str) -> np.ndarray:
1636+
return np.where(pd.isna(data).values, props, "")
1637+
16341638
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};"
16401640
)
16411641

16421642
def highlight_max(
@@ -1662,12 +1662,12 @@ def highlight_max(
16621662
-------
16631663
self : Styler
16641664
"""
1665+
1666+
def f(data: FrameOrSeries, props: str) -> np.ndarray:
1667+
return np.where(data == np.nanmax(data.values), props, "")
1668+
16651669
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};"
16711671
)
16721672

16731673
def highlight_min(
@@ -1693,12 +1693,12 @@ def highlight_min(
16931693
-------
16941694
self : Styler
16951695
"""
1696+
1697+
def f(data: FrameOrSeries, props: str) -> np.ndarray:
1698+
return np.where(data == np.nanmin(data.values), props, "")
1699+
16961700
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};"
17021702
)
17031703

17041704
@classmethod
@@ -1803,27 +1803,6 @@ def pipe(self, func: Callable, *args, **kwargs):
18031803
return com.pipe(self, func, *args, **kwargs)
18041804

18051805

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-
18271806
class _Tooltips:
18281807
"""
18291808
An extension to ``Styler`` that allows for and manipulates tooltips on hover

0 commit comments

Comments
 (0)