pandas: ENH: Raise error on ascending='False'

Is your feature request related to a problem?

when sort_values ascending parameter is set to a string (df.sort_values(col_name, ascending=‘False’) it does not error although it’s meaningless, this could be quite confusing.

Describe the solution you’d like

Raise an error if ascending is equal to values that are not boolean

API breaking implications

Error raising

Describe alternatives you’ve considered

Warning is also good, but I think error makes more sense

Additional context

for an hour I was wondering why ascending=‘False’ is not working

isinstance('False', bool) :)

About this issue

  • Original URL
  • State: closed
  • Created 3 years ago
  • Comments: 15 (3 by maintainers)

Commits related to this issue

Most upvoted comments

You can use sorted() function here. Code:

a = ("h", "b", "a", "c", "f", "d", "e", "g")
x = sorted(a)
print(x)

Output: ['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h']