-
-
Notifications
You must be signed in to change notification settings - Fork 18.4k
BUG: sort argument in unstack gives wrong results #55516
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
Comments
could be related to #54987 |
Thanks for the report, but indeed this is a duplicate. |
Is the duplicate the one I refered to (but I am not using the level argument) or another one (and which so I can subscribe to it)? |
It looks like my response in #54987 (comment) was incorrect and is more appropriate for this issue. |
3 tasks
6 tasks
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Pandas version checks
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 main branch of pandas.
Reproducible Example
Issue Description
the original series is
the default unstack() call returns a dataframe sorted on the index
while using the sort argument unstack(sort=False) gives wrong results yet a the dataframe index keeps the original order
Expected Behavior
I would expect to get the dataframe with the index in the its original order but with the proper results
(I can get this result with
sr.unstack().reindex(sr.index.get_level_values(0).unique())
)Installed Versions
INSTALLED VERSIONS
commit : e86ed37
python : 3.11.6.final.0
python-bits : 64
OS : Windows
OS-release : 10
Version : 10.0.19045
machine : AMD64
processor : AMD64 Family 23 Model 96 Stepping 1, AuthenticAMD
byteorder : little
LC_ALL : None
LANG : None
LOCALE : English_Belgium.1252
pandas : 2.1.1
numpy : 1.26.0
pytz : 2023.3.post1
dateutil : 2.8.2
setuptools : 60.2.0
pip : 23.2.1
Cython : 0.29.36
pytest : None
hypothesis : None
sphinx : None
blosc : None
feather : None
xlsxwriter : None
lxml.etree : None
html5lib : None
pymysql : None
psycopg2 : None
jinja2 : 3.1.2
IPython : 8.16.1
pandas_datareader : None
bs4 : 4.12.2
bottleneck : None
dataframe-api-compat: None
fastparquet : None
fsspec : None
gcsfs : None
matplotlib : 3.8.0
numba : None
numexpr : None
odfpy : None
openpyxl : 3.1.2
pandas_gbq : None
pyarrow : None
pyreadstat : None
pyxlsb : None
s3fs : None
scipy : None
sqlalchemy : 2.0.21
tables : None
tabulate : None
xarray : None
xlrd : None
zstandard : None
tzdata : 2023.3
qtpy : None
pyqt5 : None
The text was updated successfully, but these errors were encountered: