Rename keyword argument reverse to ascending for sorting methods #5429
Labels
breaking
Change that breaks backwards compatibility
enhancement
New feature or an improvement of an existing feature
python
Related to Python Polars
Milestone
Problem description
Summary
In Polars, the sorting methods (on expressions/series/dataframes) have a keyword argument named
reverse
. I propose to change this name toascending
.Rationale
The issue I have with
reverse
is that it does not tell me what "non reverse" / "normal" is. The docstring on for example DataFrame.sort also acknowledges this, because it says:I.e., reverse=descending, so non-reverse=ascending. You wouldn't know from the parameter name itself. Docs are good, but proper argument naming is better.
Pandas does use ascending. Pandas consistency is not a goal, but I feel Pandas has the better naming here.
PyArrow opts for the name
order
, and asks for a string to be passed in (ascending or descending). See for example array_sort_indices. As long as we can imagine having only two orderings, a bool is easier than a string imo, so I like the Pandas approach more.Moreover, I don't see a drawback in adopting this terminology, other than that we have to do a one-time breaking release.
The text was updated successfully, but these errors were encountered: