-
-
Notifications
You must be signed in to change notification settings - Fork 18.5k
TYP: sort_index #46300
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
Merged
Merged
TYP: sort_index #46300
Changes from 4 commits
Commits
Show all changes
12 commits
Select commit
Hold shift + click to select a range
38d5815
TYP: sort_index
twoertwein 89c9d4f
Merge remote-tracking branch 'upstream/main' into sort_index
twoertwein e1473f9
return type and sub-classes
twoertwein 5dd297c
remove int; add cast
twoertwein 3889f41
move SeriesT and DataFrameT
twoertwein ce6f938
return Series/DataFrame
twoertwein 17141e8
more NDFrame-compatible Series
twoertwein 122aa99
BUG: replace with value also being replaced (#46335)
lukemanley 35b9e12
REF: de-duplicate libjoin (#46256)
jbrockmendel 8adb13d
BUG: DataFrame.getattribute raising if columns have dtype string (#46…
phofl 808ff73
TST: Avoid stack overflow on Windows CI with recursion test (#46345)
mroeschke ca34ff6
Merge remote-tracking branch 'upstream/main' into sort_index
twoertwein File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -26,6 +26,7 @@ | |
Iterator, | ||
Literal, | ||
Sequence, | ||
TypeVar, | ||
cast, | ||
overload, | ||
) | ||
|
@@ -61,10 +62,12 @@ | |
IndexKeyFunc, | ||
IndexLabel, | ||
Level, | ||
NaPosition, | ||
PythonFuncType, | ||
ReadBuffer, | ||
Renamer, | ||
Scalar, | ||
SortKind, | ||
StorageOptions, | ||
Suffixes, | ||
TimedeltaConvertibleTypes, | ||
|
@@ -220,6 +223,8 @@ | |
|
||
from pandas.io.formats.style import Styler | ||
|
||
DataFrameT = TypeVar("DataFrameT", bound="DataFrame") | ||
|
||
# --------------------------------------------------------------------- | ||
# Docstring templates | ||
|
||
|
@@ -6426,19 +6431,68 @@ def sort_values( # type: ignore[override] | |
else: | ||
return result.__finalize__(self, method="sort_values") | ||
|
||
@deprecate_nonkeyword_arguments(version=None, allowed_args=["self"]) | ||
@overload | ||
def sort_index( | ||
self, | ||
*, | ||
axis: Axis = ..., | ||
level: Level | None = ..., | ||
ascending: bool | Sequence[bool] = ..., | ||
inplace: Literal[True], | ||
kind: SortKind = ..., | ||
na_position: NaPosition = ..., | ||
sort_remaining: bool = ..., | ||
ignore_index: bool = ..., | ||
key: IndexKeyFunc = ..., | ||
) -> None: | ||
... | ||
|
||
@overload | ||
def sort_index( | ||
self: DataFrameT, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. as far as I remember, pyright doesn't like self annotations that are broader than the class itself (cannot use NDFrameT). |
||
*, | ||
axis: Axis = ..., | ||
level: Level | None = ..., | ||
ascending: bool | Sequence[bool] = ..., | ||
inplace: Literal[False] = ..., | ||
kind: SortKind = ..., | ||
na_position: NaPosition = ..., | ||
sort_remaining: bool = ..., | ||
ignore_index: bool = ..., | ||
key: IndexKeyFunc = ..., | ||
) -> DataFrameT: | ||
... | ||
|
||
@overload | ||
def sort_index( | ||
self: DataFrameT, | ||
*, | ||
axis: Axis = ..., | ||
level: Level | None = ..., | ||
ascending: bool | Sequence[bool] = ..., | ||
inplace: bool = ..., | ||
kind: SortKind = ..., | ||
na_position: NaPosition = ..., | ||
sort_remaining: bool = ..., | ||
ignore_index: bool = ..., | ||
key: IndexKeyFunc = ..., | ||
) -> DataFrameT | None: | ||
... | ||
|
||
# error: Signature of "sort_index" incompatible with supertype "NDFrame" | ||
@deprecate_nonkeyword_arguments(version=None, allowed_args=["self"]) | ||
def sort_index( # type: ignore[override] | ||
Dr-Irv marked this conversation as resolved.
Show resolved
Hide resolved
|
||
self: DataFrameT, | ||
axis: Axis = 0, | ||
level: Level | None = None, | ||
ascending: bool | int | Sequence[bool | int] = True, | ||
ascending: bool | Sequence[bool] = True, | ||
inplace: bool = False, | ||
kind: str = "quicksort", | ||
na_position: str = "last", | ||
kind: SortKind = "quicksort", | ||
na_position: NaPosition = "last", | ||
sort_remaining: bool = True, | ||
ignore_index: bool = False, | ||
key: IndexKeyFunc = None, | ||
): | ||
) -> DataFrameT | None: | ||
""" | ||
Sort object by labels (along an axis). | ||
|
||
|
@@ -6529,15 +6583,15 @@ def sort_index( | |
d 4 | ||
""" | ||
return super().sort_index( | ||
axis, | ||
level, | ||
ascending, | ||
inplace, | ||
kind, | ||
na_position, | ||
sort_remaining, | ||
ignore_index, | ||
key, | ||
axis=axis, | ||
level=level, | ||
ascending=ascending, | ||
inplace=inplace, | ||
kind=kind, | ||
na_position=na_position, | ||
sort_remaining=sort_remaining, | ||
ignore_index=ignore_index, | ||
key=key, | ||
) | ||
|
||
def value_counts( | ||
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.