Skip to content

BUG: df.sort_values(by=[]) fails with IndexError #40258

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
3 tasks done
lealanko-rt opened this issue Mar 5, 2021 · 0 comments
Closed
3 tasks done

BUG: df.sort_values(by=[]) fails with IndexError #40258

lealanko-rt opened this issue Mar 5, 2021 · 0 comments
Labels
Algos Non-arithmetic algos: value_counts, factorize, sorting, isin, clip, shift, diff Bug
Milestone

Comments

@lealanko-rt
Copy link

  • 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

import pandas as pd
df = pd.DataFrame({'x': [4, 3]})
assert df.sort_values(by=[]).equals(df)

Problem description

When a dataframe is sorted by no columns, it should return the original dataframe (or at least a dataframe with some permutation of the original's rows). Instead it currently fails with an IndexError in frame.py:5451.

Expected Output

The assertion in the sample code should succeed, or at least the sort_values() call should not raise an error.

Output of pd.show_versions()

INSTALLED VERSIONS

commit : 7d32926
python : 3.7.3.final.0
python-bits : 64
OS : Linux
OS-release : 4.4.0-17763-Microsoft
Version : #864-Microsoft Thu Nov 07 15:22:00 PST 2019
machine : x86_64
processor :
byteorder : little
LC_ALL : C
LANG : en_US.UTF-8
LOCALE : None.None

pandas : 1.2.2
numpy : 1.20.1
pytz : 2021.1
dateutil : 2.8.1
pip : 18.1
setuptools : 40.8.0
Cython : 0.29.22
pytest : None
hypothesis : None
sphinx : 3.4.3
blosc : None
feather : None
xlsxwriter : None
lxml.etree : 4.4.2
html5lib : 1.0.1
pymysql : None
psycopg2 : None
jinja2 : 2.11.2
IPython : 5.8.0
pandas_datareader: None
bs4 : 4.7.1
bottleneck : None
fsspec : None
fastparquet : None
gcsfs : None
matplotlib : 3.0.2
numexpr : 2.6.9
odfpy : None
openpyxl : None
pandas_gbq : None
pyarrow : None
pyxlsb : None
s3fs : None
scipy : 1.1.0
sqlalchemy : None
tables : 3.4.4
tabulate : 0.8.2
xarray : None
xlrd : None
xlwt : None
numba : None

@lealanko-rt lealanko-rt added Bug Needs Triage Issue that has not been reviewed by a pandas team member labels Mar 5, 2021
@dsaxton dsaxton added Algos Non-arithmetic algos: value_counts, factorize, sorting, isin, clip, shift, diff and removed Needs Triage Issue that has not been reviewed by a pandas team member labels Mar 9, 2021
@jreback jreback added this to the 1.3 milestone Mar 9, 2021
@dsaxton dsaxton closed this as completed Mar 12, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Algos Non-arithmetic algos: value_counts, factorize, sorting, isin, clip, shift, diff Bug
Projects
None yet
Development

No branches or pull requests

3 participants