TYP: NDFrame sort_values signature #37866
Labels
API - Consistency
Internal Consistency of API/Behavior
Duplicate Report
Duplicate issue or pull request
Needs Triage
Issue that has not been reviewed by a pandas team member
Typing
type annotations, mypy/pyright type checking
NDFrame sort_values and inheritance
The question is related to method
sort_values
ofNDFrame
,DataFrame
andSeries
.When trying to close one issue in (#37715) below
I found out that the function signatures for
NDFrame
andDataFrame
do not match because of the argumentby
.That was the cause of the mypy error.
For
Series.sort_values
it is reasonable not to haveby
, but forDataFrame
it is mandatory.So, the function signatures for
Series
andDataFrame
must be different and should not share the common interface.Presumably, currently the method
NDFrame.sort_values
only stores the docstring forDataFrame.sort_values
.It is reasonable to move the docstring to
DataFrame.sort_values
and completely remove abstract methodNDFrame.sort_values
?This will solve the problem with incorrect overriding.
The text was updated successfully, but these errors were encountered: