Skip to content

BUG: DataFrame.sort_values doesn't validate type of ascendind #42434

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
datapythonista opened this issue Jul 7, 2021 · 2 comments
Closed

BUG: DataFrame.sort_values doesn't validate type of ascendind #42434

datapythonista opened this issue Jul 7, 2021 · 2 comments
Labels
Bug Error Reporting Incorrect or improved errors from pandas good first issue

Comments

@datapythonista
Copy link
Member

xref #42358

See the next code (and ascending provided as a string, not boolean):

>>> pandas.DataFrame({'col': [3, 1, 2]}).sort_values(by='col', ascending='False')
   col
1    1
2    2
0    3

This should fail in the same way as in Series:

>>> pandas.Series([3, 1, 2]).sort_values(ascending='False')
---------------------------------------------------------------------------
ValueError                                Traceback (most recent call last)
<ipython-input-3-f05e80474e4f> in <module>
----> 1 pandas.Series([3, 1, 2]).sort_values(ascending='False')

~/miniconda3/envs/ibis-dev/lib/python3.7/site-packages/pandas/core/series.py in sort_values(self, axis, ascending, inplace, kind, na_position, ignore_index, key)
   3254 
   3255         if not is_bool(ascending):
-> 3256             raise ValueError("ascending must be boolean")
   3257 
   3258         if na_position not in ["first", "last"]:

ValueError: ascending must be boolean
@mzeitlin11
Copy link
Member

Does this cover #41634?

@datapythonista
Copy link
Member Author

Does this cover #41634?

This is a duplicate. I didn't see an issue referenced in the PR I closed, so I assumed there wasn't an issue for it. Thanks for the heads up @mzeitlin11, closing this as duplicate.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug Error Reporting Incorrect or improved errors from pandas good first issue
Projects
None yet
Development

No branches or pull requests

2 participants