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
When grouping two columns with categorical data and using sort=False, the groups are sorted anyway. If the index was not Categorical, then the output is not sorted as expected.
mroeschke
changed the title
BUG: groupby with sort=False not respected for categorical data
BUG: groupby with sort=False not respected for categorical data for MultiIndex with 2 grouping keys
Oct 5, 2022
I have checked that this issue has not already been reported.
I have confirmed this bug exists on the latest version of pandas.
(optional) I have confirmed this bug exists on the master branch of pandas.
Code Sample, a copy-pastable example
Problem description
When grouping two columns with categorical data and using
sort=False
, the groups are sorted anyway. If the index was not Categorical, then the output is not sorted as expected.Expected Output
I was hoping to get this output
Output of
pd.show_versions()
INSTALLED VERSIONS
commit : f00ed8f
python : 3.7.11.final.0
python-bits : 64
OS : Linux
OS-release : 5.4.0-77-generic
Version : #86-Ubuntu SMP Thu Jun 17 02:35:03 UTC 2021
machine : x86_64
processor : x86_64
byteorder : little
LC_ALL : None
LANG : en_GB.UTF-8
LOCALE : en_GB.UTF-8
pandas : 1.3.0
numpy : 1.17.5
pytz : 2020.1
dateutil : 2.8.1
pip : 21.1.2
setuptools : 41.2.0
Cython : 0.29.21
pytest : 6.1.1
hypothesis : None
sphinx : 3.3.1
blosc : 1.8.3
feather : None
xlsxwriter : None
lxml.etree : 4.4.3
html5lib : None
pymysql : None
psycopg2 : 2.7.7 (dt dec pq3 ext lo64)
jinja2 : 2.10.3
IPython : 7.14.0
pandas_datareader: None
bs4 : None
bottleneck : None
fsspec : None
fastparquet : 0.4.1
gcsfs : None
matplotlib : 3.1.3
numexpr : None
odfpy : None
openpyxl : 3.0.3
pandas_gbq : None
pyarrow : None
pyxlsb : None
s3fs : None
scipy : 1.4.1
sqlalchemy : None
tables : None
tabulate : None
xarray : None
xlrd : 2.0.1
xlwt : None
numba : 0.51.2
The text was updated successfully, but these errors were encountered: