Skip to content

Commit f26031e

Browse files
authored
TYP: Use Self instead of class-bound TypeVar (generic.py/frame.py/series.py) (#51493)
* TYP: Use Self for type checking * type frame.py & series.py * TYP: change Index to Self
1 parent 93b5135 commit f26031e

File tree

6 files changed

+206
-224
lines changed

6 files changed

+206
-224
lines changed

pandas/core/frame.py

+4-3
Original file line numberDiff line numberDiff line change
@@ -231,6 +231,7 @@
231231
ReadBuffer,
232232
Renamer,
233233
Scalar,
234+
Self,
234235
SortKind,
235236
StorageOptions,
236237
Suffixes,
@@ -2495,7 +2496,7 @@ def _from_arrays(
24952496
index,
24962497
dtype: Dtype | None = None,
24972498
verify_integrity: bool = True,
2498-
) -> DataFrame:
2499+
) -> Self:
24992500
"""
25002501
Create DataFrame from a list of arrays corresponding to the columns.
25012502
@@ -4597,7 +4598,7 @@ def eval(self, expr: str, *, inplace: bool = False, **kwargs) -> Any | None:
45974598

45984599
return _eval(expr, inplace=inplace, **kwargs)
45994600

4600-
def select_dtypes(self, include=None, exclude=None) -> DataFrame:
4601+
def select_dtypes(self, include=None, exclude=None) -> Self:
46014602
"""
46024603
Return a subset of the DataFrame's columns based on the column dtypes.
46034604
@@ -5015,7 +5016,7 @@ def align(
50155016
limit: int | None = None,
50165017
fill_axis: Axis = 0,
50175018
broadcast_axis: Axis | None = None,
5018-
) -> tuple[DataFrame, NDFrameT]:
5019+
) -> tuple[Self, NDFrameT]:
50195020
return super().align(
50205021
other,
50215022
join=join,

0 commit comments

Comments
 (0)