Description
-
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