-
-
Notifications
You must be signed in to change notification settings - Fork 18.4k
pandas.Series.sort_values(ascending=[False]) behaves as ascending=True #15604
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
this option is actually only for |
Shouldn't operations on similar types behave as uniformly as possible? One should not need to know what x is or even what the argument of ascending is, it should just work. Thus, one should be able to write something like: z.sort_values(ascending = order) and it should do the right thing whether x is a Series or a 1-column DataFrame. Otherwise, users need to either special case for Series vs. DataFrame or special case for 1-column versus n-columns. |
Btw, I'm teaching Python to post-graduate students and one of the major pain points are minor differences between Series and DataFrames. It just confuses them to no end and they are incredibly smart students who are learning programming from zero knowledge in less than 4 months. |
I'm also happy to contribute a fix towards making the behavior more uniform if you point me to the contributors checklist. |
well this has a different API than DataFrame naturally sorting in a dataframe can involve multiple columns ;on a series it cannot ascending is a paired argument to it follows happy to allow the listlike (len of 1) as well |
yes would accept a patch and leave the api (iow accept a 1-element list of a boolean); would need a touch of validation
… On Mar 7, 2017, at 2:15 PM, MLopez-Ibanez ***@***.***> wrote:
Thanks. Does this mean that you may accept a patch making ascending=[False] behave the same as ascending=False ?
I don't want to waste our time if there is some reason unknown to me why this is undesired behavior. Perhaps there are performance issues in that case that I cannot imagine at the moment.
—
You are receiving this because you commented.
Reply to this email directly, view it on GitHub, or mute the thread.
|
…alse (pandas-dev#15604) closes pandas-dev#15604 Author: manu <[email protected]> Closes pandas-dev#15607 from MLopez-Ibanez/series-ascending and squashes the following commits: 6678574 [manu] BUG: make Series.sort_values(ascending=[False]) behave as ascending=False (pandas-dev#15604)
Code Sample, a copy-pastable example if possible
Problem description
False and [False] behave differently. They should behave in the same way according to the documentation (and it makes sense that they do).
Expected Output
2 6
1 5
0 4
5 3
4 2
3 1
dtype: int64
2 6
1 5
0 4
5 3
4 2
3 1
dtype: int64
Output of
pd.show_versions()
pandas: 0.19.2
nose: 1.3.7
pip: 9.0.1
setuptools: 27.2.0
Cython: 0.25.2
numpy: 1.11.3
scipy: 0.18.1
statsmodels: 0.6.1
xarray: None
IPython: 5.1.0
sphinx: 1.5.1
patsy: 0.4.1
dateutil: 2.6.0
pytz: 2016.10
blosc: None
bottleneck: 1.2.0
tables: 3.2.2
numexpr: 2.6.1
matplotlib: 2.0.0
openpyxl: 2.4.1
xlrd: 1.0.0
xlwt: 1.2.0
xlsxwriter: 0.9.6
lxml: 3.7.2
bs4: 4.5.3
html5lib: None
httplib2: None
apiclient: None
sqlalchemy: 1.1.5
pymysql: None
psycopg2: None
jinja2: 2.9.4
boto: 2.45.0
pandas_datareader: None
The text was updated successfully, but these errors were encountered: