diff --git a/pandas-stubs/core/frame.pyi b/pandas-stubs/core/frame.pyi index 006a9dbd4..3cb74eee0 100644 --- a/pandas-stubs/core/frame.pyi +++ b/pandas-stubs/core/frame.pyi @@ -308,6 +308,21 @@ else: @overload def __getitem__(self, key: Hashable) -> Series: ... +_AstypeArgExt: TypeAlias = ( + AstypeArg + | Literal[ + "number", + "datetime64", + "datetime", + "integer", + "timedelta", + "timedelta64", + "datetimetz", + "datetime64[ns]", + ] +) +_AstypeArgExtList: TypeAlias = _AstypeArgExt | list[_AstypeArgExt] + class DataFrame(NDFrame, OpsMixin, _GetItemHack): __hash__: ClassVar[None] # type: ignore[assignment] # pyright: ignore[reportIncompatibleMethodOverride] @@ -458,6 +473,7 @@ class DataFrame(NDFrame, OpsMixin, _GetItemHack): def to_gbq( self, destination_table: str, + *, project_id: str | None = ..., chunksize: int | None = ..., reauth: bool = ..., @@ -524,6 +540,7 @@ class DataFrame(NDFrame, OpsMixin, _GetItemHack): def to_parquet( self, path: FilePath | WriteBuffer[bytes], + *, engine: ParquetEngine = ..., compression: Literal["snappy", "gzip", "brotli", "lz4", "zstd"] | None = ..., index: bool | None = ..., @@ -535,6 +552,7 @@ class DataFrame(NDFrame, OpsMixin, _GetItemHack): def to_parquet( self, path: None = ..., + *, engine: ParquetEngine = ..., compression: Literal["snappy", "gzip", "brotli", "lz4", "zstd"] | None = ..., index: bool | None = ..., @@ -564,6 +582,7 @@ class DataFrame(NDFrame, OpsMixin, _GetItemHack): def to_html( self, buf: FilePath | WriteBuffer[str], + *, columns: SequenceNotStr[Hashable] | Index | Series | None = ..., col_space: ColspaceArgType | None = ..., header: _bool = ..., @@ -611,6 +630,7 @@ class DataFrame(NDFrame, OpsMixin, _GetItemHack): def to_html( self, buf: None = ..., + *, columns: Sequence[Hashable] | None = ..., col_space: ColspaceArgType | None = ..., header: _bool = ..., @@ -746,27 +766,13 @@ class DataFrame(NDFrame, OpsMixin, _GetItemHack): def eval( self, expr: _str, *, inplace: Literal[False] = ..., **kwargs: Any ) -> Scalar | np.ndarray | Self | Series: ... - AstypeArgExt: TypeAlias = ( - AstypeArg - | Literal[ - "number", - "datetime64", - "datetime", - "integer", - "timedelta", - "timedelta64", - "datetimetz", - "datetime64[ns]", - ] - ) - AstypeArgExtList: TypeAlias = AstypeArgExt | list[AstypeArgExt] @overload def select_dtypes( - self, include: StrDtypeArg, exclude: AstypeArgExtList | None = ... + self, include: StrDtypeArg, exclude: _AstypeArgExtList | None = ... ) -> Never: ... @overload def select_dtypes( - self, include: AstypeArgExtList | None, exclude: StrDtypeArg + self, include: _AstypeArgExtList | None, exclude: StrDtypeArg ) -> Never: ... @overload def select_dtypes(self, exclude: StrDtypeArg) -> Never: ... @@ -775,19 +781,19 @@ class DataFrame(NDFrame, OpsMixin, _GetItemHack): @overload def select_dtypes( self, - include: AstypeArgExtList, - exclude: AstypeArgExtList | None = ..., + include: _AstypeArgExtList, + exclude: _AstypeArgExtList | None = ..., ) -> Self: ... @overload def select_dtypes( self, - include: AstypeArgExtList | None, - exclude: AstypeArgExtList, + include: _AstypeArgExtList | None, + exclude: _AstypeArgExtList, ) -> Self: ... @overload def select_dtypes( self, - exclude: AstypeArgExtList, + exclude: _AstypeArgExtList, ) -> Self: ... def insert( self, @@ -810,6 +816,7 @@ class DataFrame(NDFrame, OpsMixin, _GetItemHack): def reindex( self, labels: Axes | None = ..., + *, index: Axes | None = ..., columns: Axes | None = ..., axis: Axis | None = ..., @@ -1301,8 +1308,8 @@ class DataFrame(NDFrame, OpsMixin, _GetItemHack): def pivot( self, *, + columns: IndexLabel, index: IndexLabel = ..., - columns: IndexLabel = ..., values: IndexLabel = ..., ) -> Self: ... def pivot_table( @@ -1320,11 +1327,18 @@ class DataFrame(NDFrame, OpsMixin, _GetItemHack): ) -> Self: ... @overload def stack( - self, level: IndexLabel = ..., dropna: _bool = ..., sort: _bool = ... + self, + level: IndexLabel = ..., + *, + future_stack: Literal[True], ) -> Self | Series: ... @overload def stack( - self, level: IndexLabel = ..., future_stack: _bool = ... + self, + level: IndexLabel = ..., + dropna: _bool = ..., + sort: _bool = ..., + future_stack: Literal[False] = ..., ) -> Self | Series: ... def explode( self, column: Sequence[Hashable], ignore_index: _bool = ... @@ -1576,14 +1590,7 @@ class DataFrame(NDFrame, OpsMixin, _GetItemHack): method: Literal["pearson", "kendall", "spearman"] = ..., numeric_only: _bool = ..., ) -> Series: ... - @overload - def count( - self, axis: Axis = ..., numeric_only: _bool = ..., *, level: Level - ) -> Self: ... - @overload - def count( - self, axis: Axis = ..., level: None = ..., numeric_only: _bool = ... - ) -> Series: ... + def count(self, axis: Axis = ..., numeric_only: _bool = ...) -> Series[int]: ... def nunique(self, axis: Axis = ..., dropna: bool = ...) -> Series: ... def idxmax( self, axis: Axis = ..., skipna: _bool = ..., numeric_only: _bool = ... @@ -1780,6 +1787,7 @@ class DataFrame(NDFrame, OpsMixin, _GetItemHack): self, start_time: _str | dt.time, end_time: _str | dt.time, + inclusive: IntervalClosedType = ..., axis: Axis | None = ..., ) -> Self: ... @overload @@ -1980,8 +1988,7 @@ class DataFrame(NDFrame, OpsMixin, _GetItemHack): @final def head(self, n: int = ...) -> Self: ... @final - def infer_objects(self) -> Self: ... - # def info + def infer_objects(self, copy: _bool | None = ...) -> Self: ... @overload def interpolate( self, @@ -2077,7 +2084,6 @@ class DataFrame(NDFrame, OpsMixin, _GetItemHack): self, axis: Axis | None = ..., skipna: _bool | None = ..., - level: None = ..., numeric_only: _bool = ..., **kwargs: Any, ) -> Series: ... @@ -2085,7 +2091,6 @@ class DataFrame(NDFrame, OpsMixin, _GetItemHack): self, axis: Axis | None = ..., skipna: _bool | None = ..., - level: None = ..., numeric_only: _bool = ..., **kwargs: Any, ) -> Series: ... @@ -2117,8 +2122,6 @@ class DataFrame(NDFrame, OpsMixin, _GetItemHack): periods: int = ..., fill_method: None = ..., freq: DateOffset | dt.timedelta | _str | None = ..., - *, - axis: Axis = ..., fill_value: Scalar | NAType | None = ..., ) -> Self: ... def pop(self, item: _str) -> Series: ... @@ -2133,7 +2136,6 @@ class DataFrame(NDFrame, OpsMixin, _GetItemHack): self, axis: Axis | None = ..., skipna: _bool | None = ..., - level: None = ..., numeric_only: _bool = ..., min_count: int = ..., **kwargs: Any, @@ -2142,7 +2144,6 @@ class DataFrame(NDFrame, OpsMixin, _GetItemHack): self, axis: Axis | None = ..., skipna: _bool = ..., - level: None = ..., numeric_only: _bool = ..., min_count: int = ..., **kwargs: Any, @@ -2305,18 +2306,16 @@ class DataFrame(NDFrame, OpsMixin, _GetItemHack): self, axis: Axis | None = ..., skipna: _bool | None = ..., - level: None = ..., ddof: int = ..., numeric_only: _bool = ..., **kwargs: Any, ) -> Series: ... # Not actually positional, but used to handle removal of deprecated - def set_axis(self, labels, *, axis: Axis, copy: _bool = ...) -> Self: ... + def set_axis(self, labels, *, axis: Axis = ..., copy: _bool = ...) -> Self: ... def skew( self, axis: Axis | None = ..., skipna: _bool | None = ..., - level: None = ..., numeric_only: _bool = ..., **kwargs: Any, ) -> Series: ... @@ -2326,7 +2325,6 @@ class DataFrame(NDFrame, OpsMixin, _GetItemHack): self, axis: Axis = ..., skipna: _bool = ..., - level: None = ..., ddof: int = ..., numeric_only: _bool = ..., **kwargs: Any, @@ -2347,9 +2345,8 @@ class DataFrame(NDFrame, OpsMixin, _GetItemHack): ) -> Self: ... def sum( self, - axis: Axis | None = ..., + axis: Axis = ..., skipna: _bool | None = ..., - level: None = ..., numeric_only: _bool = ..., min_count: int = ..., **kwargs: Any, @@ -2434,6 +2431,7 @@ class DataFrame(NDFrame, OpsMixin, _GetItemHack): def to_string( self, buf: FilePath | WriteBuffer[str], + *, columns: SequenceNotStr[Hashable] | Index | Series | None = ..., col_space: int | list[int] | dict[HashableT, int] | None = ..., header: _bool | list[_str] | tuple[str, ...] = ..., @@ -2457,6 +2455,7 @@ class DataFrame(NDFrame, OpsMixin, _GetItemHack): def to_string( self, buf: None = ..., + *, columns: Sequence[Hashable] | Index | Series | None = ..., col_space: int | list[int] | dict[Hashable, int] | None = ..., header: _bool | Sequence[_str] = ..., @@ -2513,9 +2512,8 @@ class DataFrame(NDFrame, OpsMixin, _GetItemHack): ) -> Self: ... def var( self, - axis: Axis | None = ..., + axis: Axis = ..., skipna: _bool | None = ..., - level: None = ..., ddof: int = ..., numeric_only: _bool = ..., **kwargs: Any, diff --git a/pandas-stubs/core/generic.pyi b/pandas-stubs/core/generic.pyi index 04acdb22a..664c98dca 100644 --- a/pandas-stubs/core/generic.pyi +++ b/pandas-stubs/core/generic.pyi @@ -143,7 +143,8 @@ class NDFrame(indexing.IndexingMixin): def to_markdown( self, buf: FilePath | WriteBuffer[str], - mode: FileWriteMode | None = ..., + *, + mode: FileWriteMode = ..., index: _bool = ..., storage_options: StorageOptions = ..., **kwargs: Any, @@ -152,6 +153,7 @@ class NDFrame(indexing.IndexingMixin): def to_markdown( self, buf: None = ..., + *, mode: FileWriteMode | None = ..., index: _bool = ..., storage_options: StorageOptions = ..., diff --git a/pandas-stubs/core/indexes/accessors.pyi b/pandas-stubs/core/indexes/accessors.pyi index b5db84dba..6746c9dd4 100644 --- a/pandas-stubs/core/indexes/accessors.pyi +++ b/pandas-stubs/core/indexes/accessors.pyi @@ -140,7 +140,6 @@ class _DatetimeOtherOps(Generic[_DTOtherOpsDateReturnType, _DTOtherOpsTimeReturn @property def timetz(self) -> _DTOtherOpsTimeReturnType: ... -class DatetimeAndPeriodProperties(_DatetimeFieldOps[Series[int]]): ... class _DatetimeLikeOps( _DatetimeFieldOps[_DTFieldOpsReturnType], _DatetimeObjectOps[_DTFreqReturnType], diff --git a/pandas-stubs/core/indexes/base.pyi b/pandas-stubs/core/indexes/base.pyi index 7076cd095..921a8cbd0 100644 --- a/pandas-stubs/core/indexes/base.pyi +++ b/pandas-stubs/core/indexes/base.pyi @@ -280,7 +280,9 @@ class Index(IndexOpsMixin[S1]): @final def is_(self, other) -> bool: ... def __len__(self) -> int: ... - def __array__(self, dtype=...) -> np.ndarray: ... + def __array__( + self, dtype: _str | np.dtype = ..., copy: bool | None = ... + ) -> np.ndarray: ... def __array_wrap__(self, result, context=...): ... @property def dtype(self) -> DtypeObj: ... @@ -313,9 +315,9 @@ class Index(IndexOpsMixin[S1]): def names(self, names: Sequence[Hashable]) -> None: ... def set_names(self, names, *, level=..., inplace: bool = ...): ... @overload - def rename(self, name, inplace: Literal[False] = False) -> Self: ... + def rename(self, name, *, inplace: Literal[False] = False) -> Self: ... @overload - def rename(self, name, inplace: Literal[True]) -> None: ... + def rename(self, name, *, inplace: Literal[True]) -> None: ... @property def nlevels(self) -> int: ... def get_level_values(self, level: int | _str) -> Index: ... diff --git a/pandas-stubs/core/indexes/category.pyi b/pandas-stubs/core/indexes/category.pyi index 324ff9eac..bb7fae3fb 100644 --- a/pandas-stubs/core/indexes/category.pyi +++ b/pandas-stubs/core/indexes/category.pyi @@ -40,7 +40,6 @@ class CategoricalIndex(ExtensionIndex[S1], accessor.PandasDelegate): self, dtype: DtypeArg = ..., copy: bool | None = ... ) -> np.ndarray: ... def astype(self, dtype: DtypeArg, copy: bool = ...) -> Index: ... - def fillna(self, value=...): ... @property def is_unique(self) -> bool: ... @property diff --git a/pandas-stubs/core/indexes/datetimes.pyi b/pandas-stubs/core/indexes/datetimes.pyi index 40a7102cd..55d46319c 100644 --- a/pandas-stubs/core/indexes/datetimes.pyi +++ b/pandas-stubs/core/indexes/datetimes.pyi @@ -55,7 +55,6 @@ class DatetimeIndex(DatetimeTimedeltaMixin[Timestamp], DatetimeIndexProperties): copy: bool = ..., name: Hashable = ..., ) -> None: ... - def __array__(self, dtype=...) -> np.ndarray: ... def __reduce__(self): ... # various ignores needed for mypy, as we do want to restrict what can be used in # arithmetic for these types diff --git a/pandas-stubs/core/indexes/interval.pyi b/pandas-stubs/core/indexes/interval.pyi index 026c4f2af..6bb081306 100644 --- a/pandas-stubs/core/indexes/interval.pyi +++ b/pandas-stubs/core/indexes/interval.pyi @@ -221,14 +221,7 @@ class IntervalIndex(ExtensionIndex[IntervalT], IntervalMixin): def memory_usage(self, deep: bool = ...) -> int: ... @property def is_overlapping(self) -> bool: ... - # Note: tolerance no effect. It is included in all get_loc so - # that signatures are consistent with base even though it is usually not used - def get_loc( - self, - key: Label, - method: FillnaOptions | Literal["nearest"] | None = ..., - tolerance=..., - ) -> int | slice | npt.NDArray[np.bool_]: ... + def get_loc(self, key: Label) -> int | slice | npt.NDArray[np.bool_]: ... @final def get_indexer( self, diff --git a/pandas-stubs/core/indexes/multi.pyi b/pandas-stubs/core/indexes/multi.pyi index 14a21d012..cf7d51399 100644 --- a/pandas-stubs/core/indexes/multi.pyi +++ b/pandas-stubs/core/indexes/multi.pyi @@ -76,10 +76,9 @@ class MultiIndex(Index): @property def codes(self): ... def set_codes(self, codes, *, level=..., verify_integrity: bool = ...): ... - def copy( # pyright: ignore[reportIncompatibleMethodOverride] # pyrefly: ignore - self, names=..., deep: bool = ... + def copy( # type: ignore[override] # pyright: ignore[reportIncompatibleMethodOverride] # pyrefly: ignore + self, names: SequenceNotStr[Hashable] = ..., deep: bool = ... ) -> Self: ... - def __array__(self, dtype=...) -> np.ndarray: ... def view(self, cls=...): ... def __contains__(self, key) -> bool: ... @property @@ -135,8 +134,8 @@ class MultiIndex(Index): def take( self, indices, axis: int = ..., allow_fill: bool = ..., fill_value=..., **kwargs ): ... + def argsort(self, *args, na_position: NaPosition = ..., **kwargs): ... def append(self, other): ... # pyrefly: ignore - def argsort(self, *args, **kwargs): ... def repeat(self, repeats, axis=...): ... @final def where(self, cond, other=...) -> None: ... diff --git a/pandas-stubs/core/indexes/period.pyi b/pandas-stubs/core/indexes/period.pyi index 8857677c3..bd2ee053e 100644 --- a/pandas-stubs/core/indexes/period.pyi +++ b/pandas-stubs/core/indexes/period.pyi @@ -5,7 +5,6 @@ from typing import ( overload, ) -import numpy as np import pandas as pd from pandas import Index from pandas.core.indexes.accessors import PeriodIndexFieldOps @@ -53,7 +52,6 @@ class PeriodIndex(DatetimeIndexOpsMixin[pd.Period], PeriodIndexFieldOps): def __rsub__( # pyright: ignore[reportIncompatibleMethodOverride] self, other: NaTType ) -> NaTType: ... - def __array__(self, dtype=...) -> np.ndarray: ... @final def __array_wrap__(self, result, context=...): ... def asof_locs(self, where, mask): ... diff --git a/pandas-stubs/core/indexes/range.pyi b/pandas-stubs/core/indexes/range.pyi index 580bed26d..6c673e4a0 100644 --- a/pandas-stubs/core/indexes/range.pyi +++ b/pandas-stubs/core/indexes/range.pyi @@ -53,7 +53,7 @@ class RangeIndex(Index[int]): @final def get_indexer(self, target, method=..., limit=..., tolerance=...): ... def tolist(self): ... - def copy(self, name: Hashable = ..., deep: bool = ..., dtype=..., **kwargs): ... + def copy(self, name: Hashable = ..., deep: bool = ...): ... def min(self, axis=..., skipna: bool = ..., *args, **kwargs): ... def max(self, axis=..., skipna: bool = ..., *args, **kwargs): ... def argsort(self, *args, **kwargs): ... @@ -75,8 +75,8 @@ class RangeIndex(Index[int]): @property def size(self) -> int: ... def __floordiv__(self, other): ... - def all(self) -> bool: ... - def any(self) -> bool: ... + def all(self, *args, **kwargs) -> bool: ... + def any(self, *args, **kwargs) -> bool: ... @final def union( # pyrefly: ignore self, other: list[HashableT] | Index, sort=... diff --git a/pandas-stubs/core/ops/docstrings.pyi b/pandas-stubs/core/ops/docstrings.pyi index af4811e9b..e69de29bb 100644 --- a/pandas-stubs/core/ops/docstrings.pyi +++ b/pandas-stubs/core/ops/docstrings.pyi @@ -1 +0,0 @@ -reverse_op = ... diff --git a/pandas-stubs/core/series.pyi b/pandas-stubs/core/series.pyi index f9afa8115..f0dc7e7fc 100644 --- a/pandas-stubs/core/series.pyi +++ b/pandas-stubs/core/series.pyi @@ -462,7 +462,9 @@ class Series(IndexOpsMixin[S1], NDFrame): def __array_ufunc__( self, ufunc: Callable, method: _str, *inputs: Any, **kwargs: Any ): ... - def __array__(self, dtype=...) -> np.ndarray: ... + def __array__( + self, dtype: _str | np.dtype = ..., copy: bool | None = ... + ) -> np.ndarray: ... @property def axes(self) -> list: ... @final @@ -753,11 +755,7 @@ class Series(IndexOpsMixin[S1], NDFrame): observed: _bool | _NoDefaultDoNotUse = ..., dropna: _bool = ..., ) -> SeriesGroupBy[S1, Any]: ... - # need the ignore because None is Hashable - @overload - def count(self, level: None = ...) -> int: ... # type: ignore[overload-overlap] - @overload - def count(self, level: Hashable) -> Series[S1]: ... + def count(self) -> int: ... def mode(self, dropna=...) -> Series[S1]: ... def unique(self) -> np.ndarray: ... @overload @@ -800,7 +798,7 @@ class Series(IndexOpsMixin[S1], NDFrame): self, other: Series[S1], method: Literal["pearson", "kendall", "spearman"] = ..., - min_periods: int = ..., + min_periods: int | None = ..., ) -> float: ... def cov( self, other: Series[S1], min_periods: int | None = ..., ddof: int = ... @@ -932,6 +930,7 @@ class Series(IndexOpsMixin[S1], NDFrame): axis: AxisIndex = ..., kind: SortKind = ..., order: None = ..., + stable: None = ..., ) -> Series[int]: ... def nlargest( self, n: int = ..., keep: NsmallestNlargestKeep = ... @@ -943,7 +942,7 @@ class Series(IndexOpsMixin[S1], NDFrame): self, i: Level = ..., j: Level = ..., copy: _bool = ... ) -> Series[S1]: ... def reorder_levels(self, order: list) -> Series[S1]: ... - def explode(self) -> Series[S1]: ... + def explode(self, ignore_index: _bool = ...) -> Series[S1]: ... def unstack( self, level: IndexLabel = ..., @@ -1456,6 +1455,7 @@ class Series(IndexOpsMixin[S1], NDFrame): self, start_time: _str | time, end_time: _str | time, + inclusive: IntervalClosedType = ..., axis: AxisIndex | None = ..., ) -> Series[S1]: ... @final @@ -1671,8 +1671,6 @@ class Series(IndexOpsMixin[S1], NDFrame): ) -> Series[bool]: ... @overload def __and__(self, other: int | np_ndarray_anyint | Series[int]) -> Series[int]: ... - # def __array__(self, dtype: Optional[_bool] = ...) -> _np_ndarray - def __div__(self, other: num | _ListLike | Series[S1]) -> Series[S1]: ... def __eq__(self, other: object) -> Series[_bool]: ... # type: ignore[override] # pyright: ignore[reportIncompatibleMethodOverride] def __floordiv__(self, other: num | _ListLike | Series[S1]) -> Series[int]: ... def __ge__( # type: ignore[override] @@ -1745,7 +1743,6 @@ class Series(IndexOpsMixin[S1], NDFrame): ) -> Series[bool]: ... @overload def __rand__(self, other: int | np_ndarray_anyint | Series[int]) -> Series[int]: ... - def __rdiv__(self, other: num | _ListLike | Series[S1]) -> Series[S1]: ... def __rdivmod__(self, other: num | _ListLike | Series[S1]) -> Series[S1]: ... # type: ignore[override] # pyright: ignore[reportIncompatibleMethodOverride] def __rfloordiv__(self, other: num | _ListLike | Series[S1]) -> Series[S1]: ... def __rmod__(self, other: num | _ListLike | Series[S1]) -> Series[S1]: ... @@ -1755,7 +1752,6 @@ class Series(IndexOpsMixin[S1], NDFrame): ) -> TimedeltaSeries: ... @overload def __rmul__(self, other: num | _ListLike | Series) -> Series: ... - def __rnatmul__(self, other: num | _ListLike | Series[S1]) -> Series[S1]: ... def __rpow__(self, other: num | _ListLike | Series[S1]) -> Series[S1]: ... # ignore needed for mypy as we want different results based on the arguments @overload # type: ignore[override] @@ -1982,11 +1978,15 @@ class Series(IndexOpsMixin[S1], NDFrame): min_periods: int = ..., adjust: _bool = ..., ignore_na: _bool = ..., + axis: Axes = ..., + times: np.ndarray | Series | None = ..., + method: CalculationMethod = ..., ) -> ExponentialMovingWindow[Series]: ... @final def expanding( self, min_periods: int = ..., + axis: Literal[0] = ..., method: CalculationMethod = ..., ) -> Expanding[Series]: ... def floordiv( @@ -2016,7 +2016,6 @@ class Series(IndexOpsMixin[S1], NDFrame): self, axis: AxisIndex | None = ..., skipna: _bool = ..., - level: None = ..., numeric_only: _bool = ..., **kwargs: Any, ) -> Scalar: ... @@ -2024,7 +2023,6 @@ class Series(IndexOpsMixin[S1], NDFrame): self, axis: AxisIndex | None = ..., skipna: _bool = ..., - level: None = ..., numeric_only: _bool = ..., **kwargs: Any, ) -> Scalar: ... diff --git a/pandas-stubs/core/window/rolling.pyi b/pandas-stubs/core/window/rolling.pyi index 06774ef1a..f601d2d4f 100644 --- a/pandas-stubs/core/window/rolling.pyi +++ b/pandas-stubs/core/window/rolling.pyi @@ -97,6 +97,7 @@ class RollingAndExpandingMixin(BaseWindow[NDFrameT]): def max( self, numeric_only: bool = ..., + *args, engine: WindowingEngine = ..., engine_kwargs: WindowingEngineKwargs = ..., ) -> NDFrameT: ... diff --git a/tests/series/test_series.py b/tests/series/test_series.py index f58d651f4..49fd80962 100644 --- a/tests/series/test_series.py +++ b/tests/series/test_series.py @@ -33,6 +33,8 @@ from pandas.core.arrays.datetimes import DatetimeArray from pandas.core.arrays.timedeltas import TimedeltaArray from pandas.core.window import ExponentialMovingWindow +from pandas.core.window.expanding import Expanding +from pandas.core.window.rolling import Rolling import pytest from typing_extensions import ( Never, @@ -1216,14 +1218,10 @@ def test_types_plot() -> None: def test_types_window() -> None: s = pd.Series([0, 1, 1, 0, 5, 1, -10]) - s.expanding() - s.rolling(2, center=True) - if TYPE_CHECKING_INVALID_USAGE: - s.expanding(axis=0) # type: ignore[call-arg] # pyright: ignore[reportCallIssue] - s.rolling(2, axis=0, center=True) # type: ignore[call-overload] # pyright: ignore[reportCallIssue] - s.expanding(axis=0, center=True) # type: ignore[call-arg] # pyright: ignore[reportCallIssue] + check(assert_type(s.expanding(), "Expanding[pd.Series]"), Expanding) + check(assert_type(s.rolling(2, center=True), "Rolling[pd.Series]"), Rolling) - s.rolling(2) + check(assert_type(s.rolling(2), "Rolling[pd.Series]"), Rolling) check( assert_type(s.rolling(2).agg("sum"), pd.Series), @@ -1522,14 +1520,13 @@ def test_types_bfill() -> None: def test_types_ewm() -> None: s1 = pd.Series([1, 2, 3]) - if TYPE_CHECKING_INVALID_USAGE: - check( - assert_type( - s1.ewm(com=0.3, min_periods=0, adjust=False, ignore_na=True, axis=0), # type: ignore[call-arg] # pyright: ignore[reportAssertTypeFailure,reportCallIssue] - "ExponentialMovingWindow[pd.Series]", - ), - ExponentialMovingWindow, - ) + check( + assert_type( + s1.ewm(com=0.3, min_periods=0, adjust=False, ignore_na=True), + "ExponentialMovingWindow[pd.Series]", + ), + ExponentialMovingWindow, + ) check( assert_type( s1.ewm(com=0.3, min_periods=0, adjust=False, ignore_na=True), @@ -3993,3 +3990,11 @@ def test_series_str_methods() -> None: check(assert_type(s_str, "pd.Series[str]"), pd.Series, str) check(assert_type(s_str.str.upper(), "pd.Series[str]"), pd.Series, str) check(assert_type(s_str.str.lower(), "pd.Series[str]"), pd.Series, str) + + +def test_series_explode() -> None: + """Test Series.explode method.""" + s = pd.Series([[1, 2, 3], "foo", [], [3, 4]]) + + check(assert_type(s.explode(), pd.Series), pd.Series) + check(assert_type(s.explode(ignore_index=True), pd.Series), pd.Series) diff --git a/tests/test_frame.py b/tests/test_frame.py index 2973d25cb..b2348fc30 100644 --- a/tests/test_frame.py +++ b/tests/test_frame.py @@ -2756,7 +2756,7 @@ def test_dataframe_pct_change() -> None: check(assert_type(df.pct_change(), pd.DataFrame), pd.DataFrame) check(assert_type(df.pct_change(fill_method=None), pd.DataFrame), pd.DataFrame) check( - assert_type(df.pct_change(axis="columns", periods=-1), pd.DataFrame), + assert_type(df.pct_change(periods=-1), pd.DataFrame), pd.DataFrame, ) check(assert_type(df.pct_change(fill_value=0), pd.DataFrame), pd.DataFrame)