Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 7 additions & 10 deletions pandas-stubs/core/algorithms.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,7 @@ from pandas._typing import (
ShapeT,
TakeIndexer,
np_1darray,
np_1darray_dt,
np_1darray_int64,
np_1darray_td,
np_ndarray,
)

Expand All @@ -38,18 +36,17 @@ def unique(values: IntervalIndex[IntervalT]) -> IntervalIndex[IntervalT]: ...
@overload
def unique(values: PeriodIndex) -> PeriodIndex: ...
@overload
# switch to DatetimeIndex after Pandas 3.0
def unique(values: DatetimeIndex) -> np_1darray_dt | DatetimeIndex: ...
def unique(values: DatetimeIndex) -> DatetimeIndex: ...
@overload
# switch to TimedeltaIndex after Pandas 3.0
def unique(values: TimedeltaIndex) -> np_1darray_td: ...
def unique(values: TimedeltaIndex) -> TimedeltaIndex: ...
@overload
# switch to Index[int] after Pandas 3.0
def unique(values: RangeIndex) -> np_1darray_int64: ...
def unique(values: RangeIndex) -> Index[int]: ...
@overload
def unique(values: MultiIndex) -> np_ndarray: ...
def unique( # type: ignore[overload-overlap] # pyright: ignore[reportOverlappingOverload]
values: MultiIndex,
) -> np_ndarray: ...
@overload
def unique(values: Index) -> np_1darray | Index: ... # switch to Index after Pandas 3.0
def unique(values: Index) -> Index: ...
@overload
def unique(values: Categorical) -> Categorical: ...

Expand Down
7 changes: 3 additions & 4 deletions pandas-stubs/core/arrays/datetimes.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ from pandas.core.arrays.datetimelike import (
TimelikeOps,
)
from pandas.core.arrays.period import PeriodArray
from pandas.core.arrays.string_ import BaseStringArray
from pandas.core.indexes.datetimes import DatetimeIndex
from pandas.core.series import Series

Expand Down Expand Up @@ -62,10 +63,8 @@ class DatetimeArray(TimelikeOps, DatelikeOps):
def to_pydatetime(self) -> np_1darray_object: ...
def normalize(self) -> Self: ...
def to_period(self, freq: Frequency | None = None) -> PeriodArray: ...
# TODO: BaseStringArray after Pandas 3.0 pandas-dev/pandas#57064
def month_name(self, locale: str | None = None) -> np_1darray_object: ...
# TODO: BaseStringArray after Pandas 3.0 pandas-dev/pandas#57064
def day_name(self, locale: str | None = None) -> np_1darray_object: ...
def month_name(self, locale: str | None = None) -> BaseStringArray: ...
def day_name(self, locale: str | None = None) -> BaseStringArray: ...
@property
def time(self) -> np_1darray_object: ...
@property
Expand Down
187 changes: 13 additions & 174 deletions pandas-stubs/core/frame.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -813,14 +813,14 @@ class DataFrame(NDFrame, OpsMixin, _GetItemHack):
self,
expr: _str,
*,
inplace: Literal[False] = False,
parser: Literal["pandas", "python"] = ...,
engine: Literal["python", "numexpr"] | None = ...,
local_dict: dict[_str, Any] | None = ...,
global_dict: dict[_str, Any] | None = ...,
resolvers: MutableSequence[Mapping[Any, Any]] | None = ...,
level: int = ...,
target: object | None = ...,
inplace: Literal[False] = False,
) -> Self: ...
@overload
def eval(self, expr: _str, *, inplace: Literal[True], **kwargs: Any) -> None: ...
Expand Down Expand Up @@ -889,20 +889,6 @@ class DataFrame(NDFrame, OpsMixin, _GetItemHack):
limit: int | None = None,
tolerance: float | Timedelta | None = ...,
) -> Self: ...
@overload
def rename(
self,
mapper: Renamer | None = ...,
*,
index: Renamer | None = ...,
columns: Renamer | None = ...,
axis: Axis | None = ...,
copy: bool = ...,
inplace: Literal[True],
level: Level | None = None,
errors: IgnoreRaise = ...,
) -> None: ...
@overload
def rename(
self,
mapper: Renamer | None = ...,
Expand All @@ -911,46 +897,24 @@ class DataFrame(NDFrame, OpsMixin, _GetItemHack):
columns: Renamer | None = ...,
axis: Axis | None = ...,
copy: bool = ...,
inplace: Literal[False] = False,
inplace: bool = False,
level: Level | None = None,
errors: IgnoreRaise = ...,
) -> Self: ...
@overload
def fillna(
self,
value: Scalar | NAType | dict[Any, Any] | Series | DataFrame | None = ...,
*,
axis: Axis | None = ...,
limit: int = ...,
inplace: Literal[True],
# TODO: pandas-dev/pandas#63195 return Self after Pandas 3.0
) -> None: ...
@overload
def fillna(
self,
value: Scalar | NAType | dict[Any, Any] | Series | DataFrame | None = ...,
*,
axis: Axis | None = ...,
limit: int = ...,
inplace: Literal[False] = False,
inplace: bool = False,
) -> Self: ...
@overload
def replace(
self,
to_replace: ReplaceValue | Mapping[HashableT2, ReplaceValue] = ...,
value: ReplaceValue | Mapping[HashableT3, ReplaceValue] = ...,
*,
inplace: Literal[True],
regex: ReplaceValue | Mapping[HashableT3, ReplaceValue] = ...,
# TODO: pandas-dev/pandas#63195 return Self after Pandas 3.0
) -> None: ...
@overload
def replace(
self,
to_replace: ReplaceValue | Mapping[HashableT2, ReplaceValue] = ...,
value: ReplaceValue | Mapping[HashableT3, ReplaceValue] = ...,
*,
inplace: Literal[False] = False,
inplace: bool = False,
regex: ReplaceValue | Mapping[HashableT3, ReplaceValue] = ...,
) -> Self: ...
def shift(
Expand Down Expand Up @@ -1373,20 +1337,10 @@ class DataFrame(NDFrame, OpsMixin, _GetItemHack):
observed: _bool = True,
sort: _bool = True,
) -> Self: ...
@overload
def stack(
self,
level: IndexLabel = ...,
*,
future_stack: Literal[True],
) -> Self | Series: ...
@overload
def stack(
self,
level: IndexLabel = ...,
dropna: _bool = ...,
sort: _bool = ...,
future_stack: Literal[False] = False,
future_stack: Literal[True] = True,
) -> Self | Series: ...
def explode(
self, column: Sequence[Hashable], ignore_index: _bool = False
Expand Down Expand Up @@ -1942,22 +1896,11 @@ class DataFrame(NDFrame, OpsMixin, _GetItemHack):
inclusive: IntervalClosedType = "both",
axis: Axis | None = 0,
) -> Self: ...
@overload
def bfill(
self,
*,
axis: Axis | None = None,
inplace: Literal[True],
limit: int | None = ...,
limit_area: Literal["inside", "outside"] | None = ...,
# TODO: pandas-dev/pandas#63195 return Self after Pandas 3.0
) -> None: ...
@overload
def bfill(
self,
*,
axis: Axis | None = None,
inplace: Literal[False] = False,
inplace: bool = False,
limit: int | None = ...,
limit_area: Literal["inside", "outside"] | None = ...,
) -> Self: ...
Expand All @@ -1968,7 +1911,7 @@ class DataFrame(NDFrame, OpsMixin, _GetItemHack):
upper: float | None = ...,
*,
axis: Axis | None = ...,
inplace: Literal[False] = False,
inplace: bool = False,
**kwargs: Any,
) -> Self: ...
@overload
Expand All @@ -1978,7 +1921,7 @@ class DataFrame(NDFrame, OpsMixin, _GetItemHack):
upper: AnyArrayLike | None = ...,
*,
axis: Axis = ...,
inplace: Literal[False] = False,
inplace: bool = False,
**kwargs: Any,
) -> Self: ...
@overload
Expand All @@ -1988,52 +1931,9 @@ class DataFrame(NDFrame, OpsMixin, _GetItemHack):
upper: AnyArrayLike = ...,
*,
axis: Axis = ...,
inplace: Literal[False] = False,
**kwargs: Any,
) -> Self: ...
@overload
def clip( # pyright: ignore[reportOverlappingOverload]
self,
lower: None = None,
upper: None = None,
*,
axis: Axis | None = ...,
inplace: Literal[True],
inplace: bool = False,
**kwargs: Any,
) -> Self: ...
@overload
def clip(
self,
lower: float | None = ...,
upper: float | None = ...,
*,
axis: Axis | None = ...,
inplace: Literal[True],
**kwargs: Any,
# TODO: pandas-dev/pandas#63195 return Self after Pandas 3.0
) -> None: ...
@overload
def clip(
self,
lower: AnyArrayLike = ...,
upper: AnyArrayLike | None = ...,
*,
axis: Axis = ...,
inplace: Literal[True],
**kwargs: Any,
# TODO: pandas-dev/pandas#63195 return Self after Pandas 3.0
) -> None: ...
@overload
def clip(
self,
lower: AnyArrayLike | None = ...,
upper: AnyArrayLike = ...,
*,
axis: Axis = ...,
inplace: Literal[True],
**kwargs: Any,
# TODO: pandas-dev/pandas#63195 return Self after Pandas 3.0
) -> None: ...
@final
def copy(self, deep: _bool = True) -> Self: ...
def cummax(
Expand Down Expand Up @@ -2109,22 +2009,11 @@ class DataFrame(NDFrame, OpsMixin, _GetItemHack):
axis: AxisIndex = 0,
method: CalculationMethod = "single",
) -> Expanding[Self]: ...
@overload
def ffill(
self,
*,
axis: Axis | None = ...,
inplace: Literal[True],
limit: int | None = ...,
limit_area: Literal["inside", "outside"] | None = ...,
# TODO: pandas-dev/pandas#63195 return Self after Pandas 3.0
) -> None: ...
@overload
def ffill(
self,
*,
axis: Axis | None = ...,
inplace: Literal[False] = False,
inplace: bool = False,
limit: int | None = ...,
limit_area: Literal["inside", "outside"] | None = ...,
) -> Self: ...
Expand Down Expand Up @@ -2168,20 +2057,6 @@ class DataFrame(NDFrame, OpsMixin, _GetItemHack):
def head(self, n: int = 5) -> Self: ...
@final
def infer_objects(self, copy: _bool | None = ...) -> Self: ...
@overload
def interpolate(
self,
method: InterpolateOptions = ...,
*,
axis: Axis = 0,
limit: int | None = ...,
limit_direction: Literal["forward", "backward", "both"] = ...,
limit_area: Literal["inside", "outside"] | None = ...,
inplace: Literal[True],
**kwargs: Any,
# TODO: pandas-dev/pandas#63195 return Self after Pandas 3.0
) -> None: ...
@overload
def interpolate(
self,
method: InterpolateOptions = ...,
Expand All @@ -2190,7 +2065,7 @@ class DataFrame(NDFrame, OpsMixin, _GetItemHack):
limit: int | None = ...,
limit_direction: Literal["forward", "backward", "both"] = ...,
limit_area: Literal["inside", "outside"] | None = ...,
inplace: Literal[False] = False,
inplace: bool = False,
**kwargs: Any,
) -> Self: ...
def keys(self) -> Index: ...
Expand Down Expand Up @@ -2222,24 +2097,6 @@ class DataFrame(NDFrame, OpsMixin, _GetItemHack):
axis: Axis = "columns",
level: Level | None = None,
) -> Self: ...
@overload
def mask(
self,
cond: (
Series
| DataFrame
| np_ndarray_bool
| Callable[[DataFrame], DataFrame]
| Callable[[Any], _bool]
),
other: Scalar | Series | DataFrame | Callable[..., Any] | NAType | None = ...,
*,
inplace: Literal[True],
axis: Axis | None = ...,
level: Level | None = None,
# TODO: pandas-dev/pandas#63195 return Self after Pandas 3.0
) -> None: ...
@overload
def mask(
self,
cond: (
Expand All @@ -2250,8 +2107,8 @@ class DataFrame(NDFrame, OpsMixin, _GetItemHack):
| Callable[[Any], _bool]
),
other: Scalar | Series | DataFrame | Callable[..., Any] | NAType | None = ...,
inplace: bool = False,
*,
inplace: Literal[False] = False,
axis: Axis | None = ...,
level: Level | None = None,
) -> Self: ...
Expand Down Expand Up @@ -2703,24 +2560,6 @@ class DataFrame(NDFrame, OpsMixin, _GetItemHack):
numeric_only: _bool = False,
**kwargs: Any,
) -> Series: ...
@overload
def where(
self,
cond: (
Series
| DataFrame
| np_ndarray_bool
| Callable[[DataFrame], DataFrame]
| Callable[[Any], _bool]
),
other: Scalar | Self | Callable[..., Scalar | Self] = ...,
*,
inplace: Literal[True],
axis: Axis | None = ...,
level: Level | None = None,
# TODO: pandas-dev/pandas#63195 return Self after Pandas 3.0
) -> None: ...
@overload
def where(
self,
cond: (
Expand All @@ -2732,7 +2571,7 @@ class DataFrame(NDFrame, OpsMixin, _GetItemHack):
),
other: Scalar | Self | Callable[..., Scalar | Self] = ...,
*,
inplace: Literal[False] = False,
inplace: bool = False,
axis: Axis | None = ...,
level: Level | None = None,
) -> Self: ...
Expand Down
Loading