You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
In the above example, the sort_index method on DataFrame object does not sort MultiIndex properly when the ascending parameter is passed as tuple. The sorted2.index should be sorted in ascending order for level 0 (class) and descending order for level 1 (animal). However, this is not the case and level 1 is also ascending:
Sorry about that @phofl I thought I was using the latest version but I was probably in wrong virtual environment... If it's OK with you I could submit a PR with a test that provides ascending param with a tuple?
Yeah for sure. You could also check if there is an existing test and parametrize that one. Not sure if there is though. Have checked yesterday if we have a test for tuples but could not find anything
Uh oh!
There was an error while loading. Please reload this page.
I have checked that this issue has not already been reported.
I have confirmed this bug exists on the latest version of pandas.
I have confirmed this bug exists on the master branch of pandas.
Reproducible Example
Issue Description
In the above example, the
sort_index
method on DataFrame object does not sort MultiIndex properly when theascending
parameter is passed as tuple. Thesorted2.index
should be sorted in ascending order for level 0 (class
) and descending order for level 1 (animal
). However, this is not the case and level 1 is also ascending:When the
ascending
parameter is list than thesort_index
method works as expected such that level 0 is ascending and level 1 is descending:Expected Behavior
I would expect
sorted1.index
andsorted2.index
to be equal (i.e., include a test case withassert sorted1.index == sorted2.index
that passes).Installed Versions
INSTALLED VERSIONS
commit : b5958ee
python : 3.6.9.final.0
python-bits : 64
OS : Linux
OS-release : 5.4.0-84-generic
Version : #94~18.04.1-Ubuntu SMP Thu Aug 26 23:17:46 UTC 2021
machine : x86_64
processor : x86_64
byteorder : little
LC_ALL : None
LANG : en_US.UTF-8
LOCALE : en_US.UTF-8
pandas : 1.1.5
numpy : 1.19.5
pytz : 2021.3
dateutil : 2.8.2
pip : 21.2.4
setuptools : 58.2.0
Cython : None
pytest : None
hypothesis : None
sphinx : None
blosc : None
feather : None
xlsxwriter : None
lxml.etree : None
html5lib : None
pymysql : None
psycopg2 : None
jinja2 : None
IPython : 7.16.1
pandas_datareader: None
bs4 : None
bottleneck : None
fsspec : None
fastparquet : None
gcsfs : None
matplotlib : None
numexpr : None
odfpy : None
openpyxl : None
pandas_gbq : None
pyarrow : None
pytables : None
pyxlsb : None
s3fs : None
scipy : None
sqlalchemy : None
tables : None
tabulate : None
xarray : None
xlrd : None
xlwt : None
numba : None
The text was updated successfully, but these errors were encountered: