@@ -1734,6 +1734,7 @@ def highlight_range(
1734
1734
--------
1735
1735
Styler.highlight_max:
1736
1736
Styler.highlight_min:
1737
+ Styler.highlight_quantile:
1737
1738
1738
1739
Notes
1739
1740
-----
@@ -1952,25 +1953,15 @@ def _highlight_func(
1952
1953
return np .where (pd .isna (data ).values , props , "" )
1953
1954
elif highlight == "range" :
1954
1955
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 , "" )
1958
1959
elif highlight == "quantile" :
1959
1960
l , h = kwargs .get ("q_low" ), kwargs .get ("q_high" )
1960
1961
if l > 0 :
1961
1962
q , tgt_label = [0 , l , h ], 1
1962
1963
else :
1963
1964
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]")
1974
1965
if kwargs .get ("axis_" ) is None :
1975
1966
shape = data .values .shape
1976
1967
labels = pd .qcut (data .values .ravel (), q = q , labels = False ).reshape (shape )
0 commit comments