Skip to content

MultiLevelIndex sort_index already does support ascending as a list of booleans #31880

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
petrbel opened this issue Feb 11, 2020 · 0 comments · Fixed by #31898
Closed

MultiLevelIndex sort_index already does support ascending as a list of booleans #31880

petrbel opened this issue Feb 11, 2020 · 0 comments · Fixed by #31898

Comments

@petrbel
Copy link

petrbel commented Feb 11, 2020

Code Sample, a copy-pastable example if possible

df.sort_index(level=[1, 0], ascending=[True, False])

Problem description

The documentation states that pandas.DataFrame.sort_index parameter accepts is a boolean. However, in the case of multi level index, it can (already) be a list of booleans indicating which level should ascending and which descending.

Both lexsort_indexer and sort_levels support this behavior.

I suggest updating both tests and documentation.

Output of pd.show_versions()

INSTALLED VERSIONS

commit : None
python : 3.8.0.final.0
python-bits : 64
OS : Linux
OS-release : 5.4.14-arch1-1
machine : x86_64
processor :
byteorder : little
LC_ALL : None
LANG : en_US.UTF8
LOCALE : en_US.UTF-8

pandas : 1.0.0
numpy : 1.18.1
pytz : 2019.3
dateutil : 2.8.1
pip : 20.0.2
setuptools : 45.1.0
Cython : 0.29.14
pytest : 5.3.5
hypothesis : None
sphinx : None
blosc : None
feather : None
xlsxwriter : None
lxml.etree : 4.5.0
html5lib : None
pymysql : None
psycopg2 : None
jinja2 : 2.11.1
IPython : 7.11.1
pandas_datareader: None
bs4 : 4.8.2
bottleneck : None
fastparquet : None
gcsfs : None
lxml.etree : 4.5.0
matplotlib : 3.1.2
numexpr : None
odfpy : None
openpyxl : None
pandas_gbq : None
pyarrow : None
pytables : None
pytest : 5.3.5
pyxlsb : None
s3fs : None
scipy : 1.4.1
sqlalchemy : None
tables : None
tabulate : None
xarray : None
xlrd : None
xlwt : None
xlsxwriter : None
numba : None

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant