Pandas version checks
-
[X] I have checked that this issue has not already been reported.
-
[X] I have confirmed this bug exists on the latest version of pandas.
-
[X] I have confirmed this bug exists on the main branch of pandas.
Reproducible Example
import pandas as pd
import numpy as np
import matplotlib as mpl
df = pd.DataFrame([[38.0, 2.0, 18.0, 22.0, 21, np.nan],[19, 439, 6, 452, 226,232]],
index=pd.Index(['Tumour (Positive)', 'Non-Tumour (Negative)'], name='Actual Label:'),
columns=pd.MultiIndex.from_product([['Decision Tree', 'Regression', 'Random'],['Tumour', 'Non-Tumour']], names=['Model:', 'Predicted:']))
# works in loc
df.loc[("Non-Tumour (Negative)", ...)]
def highlight_max(x,):
return np.where(x == np.nanmax(x.to_numpy()), f"color: blue;", None)
# works with columns
df.style.apply(highlight_max, subset=("Non-Tumour (Negative)", df.columns), axis=0)
# not work with ellipsis
df.style.apply(lambda x: x, subset=("Non-Tumour (Negative)", ...), axis=1)
Issue Description
Subset parameter is documented as A valid 2d input to DataFrame.loc[<subset>]
But when subset rows in styler, ellipsis not works.
Expected Behavior
subset=("Non-Tumour (Negative)", ...)
works the same as subset=("Non-Tumour (Negative)", df.columns)
Installed Versions
INSTALLED VERSIONS
------------------
commit : 8dab54d6573f7186ff0c3b6364d5e4dd635ff3e7
python : 3.10.4.final.0
python-bits : 64
OS : Linux
OS-release : 5.10.102.1-microsoft-standard-WSL2
Version : #1 SMP Wed Mar 2 00:30:59 UTC 2022
machine : x86_64
processor : x86_64
byteorder : little
LC_ALL : None
LANG : C.UTF-8
LOCALE : en_US.UTF-8
pandas : 1.5.2
numpy : 1.21.5
pytz : 2022.1
dateutil : 2.8.2
setuptools : 65.3.0
pip : 22.3.1
Cython : None
pytest : 7.1.3
hypothesis : None
sphinx : 4.3.2
blosc : None
feather : None
xlsxwriter : 3.0.3
lxml.etree : 4.9.1
html5lib : 1.1
pymysql : None
psycopg2 : 2.9.5
jinja2 : 3.1.2
IPython : 8.4.0
pandas_datareader: None
bs4 : 4.11.1
bottleneck : None
brotli : None
fastparquet : None
fsspec : None
gcsfs : None
matplotlib : 3.5.3
numba : 0.55.2
numexpr : None
odfpy : None
openpyxl : 3.0.10
pandas_gbq : None
pyarrow : 8.0.0
pyreadstat : None
pyxlsb : None
s3fs : None
scipy : 1.8.0
snappy : None
sqlalchemy : 1.4.39
tables : None
tabulate : 0.9.0
xarray : None
xlrd : None
xlwt : None
zstandard : None
tzdata : 2022.1
Comment From: attack68
related to #46685
Comment From: attack68
This needs consideration about how to restructure the Styler columns/rows selection code, or a re-documentation.
Comment From: attack68
closing to be solved via #46685