Skip to content

Commit 7dbc684

Browse files
committed
quantile add
1 parent 4ede159 commit 7dbc684

File tree

1 file changed

+4
-13
lines changed

1 file changed

+4
-13
lines changed

pandas/io/formats/style.py

Lines changed: 4 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1734,6 +1734,7 @@ def highlight_range(
17341734
--------
17351735
Styler.highlight_max:
17361736
Styler.highlight_min:
1737+
Styler.highlight_quantile:
17371738
17381739
Notes
17391740
-----
@@ -1952,25 +1953,15 @@ def _highlight_func(
19521953
return np.where(pd.isna(data).values, props, "")
19531954
elif highlight == "range":
19541955
l, h = kwargs.get("start"), kwargs.get("stop")
1955-
in_l = data >= l if l is not None else np.full_like(data, True, dtype=bool)
1956-
in_h = data <= h if h is not None else np.full_like(data, True, dtype=bool)
1957-
return np.where(in_l & in_h, props, "")
1956+
ge_l = data >= l if l is not None else np.full_like(data, True, dtype=bool)
1957+
le_h = data <= h if h is not None else np.full_like(data, True, dtype=bool)
1958+
return np.where(ge_l & le_h, props, "")
19581959
elif highlight == "quantile":
19591960
l, h = kwargs.get("q_low"), kwargs.get("q_high")
19601961
if l > 0:
19611962
q, tgt_label = [0, l, h], 1
19621963
else:
19631964
q, tgt_label = [0, h], 0
1964-
# if l > 0 and h < 1:
1965-
# q, tgt_label = [0, l, h, 1], 1
1966-
# elif l > 0 and h == 1:
1967-
# q, tgt_label = [0, l, h], 1
1968-
# elif l == 0 and h < 1:
1969-
# q, tgt_label = [0, h, 1], 0
1970-
# elif l == 0 and h == 1:
1971-
# q, tgt_label = [0, 1], 0
1972-
# else:
1973-
# raise ValueError("'q_low' and 'q_high' must be in range [0,1]")
19741965
if kwargs.get("axis_") is None:
19751966
shape = data.values.shape
19761967
labels = pd.qcut(data.values.ravel(), q=q, labels=False).reshape(shape)

0 commit comments

Comments
 (0)