diff --git a/pandas-stubs/core/arrays/sparse/array.pyi b/pandas-stubs/core/arrays/sparse/array.pyi index 1e4b1e72..16227595 100644 --- a/pandas-stubs/core/arrays/sparse/array.pyi +++ b/pandas-stubs/core/arrays/sparse/array.pyi @@ -1,6 +1,7 @@ from enum import Enum from typing import ( Any, + final, overload, ) @@ -16,6 +17,7 @@ from pandas._typing import ( SequenceIndexer, ) +@final class ellipsis(Enum): Ellipsis = "..." diff --git a/pandas-stubs/core/frame.pyi b/pandas-stubs/core/frame.pyi index 47a8864f..ed389281 100644 --- a/pandas-stubs/core/frame.pyi +++ b/pandas-stubs/core/frame.pyi @@ -19,6 +19,7 @@ from typing import ( Generic, Literal, NoReturn, + final, overload, ) @@ -705,6 +706,7 @@ class DataFrame(NDFrame, OpsMixin, _GetItemHack): def transpose(self, *args: Any, copy: _bool = ...) -> Self: ... @property def T(self) -> Self: ... + @final def __getattr__(self, name: str) -> Series: ... def isetitem( self, loc: int | Sequence[int], value: Scalar | ArrayLike | list[Any] @@ -795,6 +797,7 @@ class DataFrame(NDFrame, OpsMixin, _GetItemHack): allow_duplicates: _bool = ..., ) -> None: ... def assign(self, **kwargs: IntoColumn) -> Self: ... + @final def align( self, other: NDFrameT, @@ -1700,6 +1703,7 @@ class DataFrame(NDFrame, OpsMixin, _GetItemHack): @property def values(self) -> np.ndarray: ... # methods + @final def abs(self) -> Self: ... def add( self, @@ -1708,7 +1712,9 @@ class DataFrame(NDFrame, OpsMixin, _GetItemHack): level: Level | None = ..., fill_value: float | None = ..., ) -> Self: ... + @final def add_prefix(self, prefix: _str, axis: Axis | None = None) -> Self: ... + @final def add_suffix(self, suffix: _str, axis: Axis | None = None) -> Self: ... @overload def all( @@ -1744,7 +1750,9 @@ class DataFrame(NDFrame, OpsMixin, _GetItemHack): skipna: _bool = ..., **kwargs: Any, ) -> Series[_bool]: ... + @final def asof(self, where, subset: _str | list[_str] | None = ...) -> Self: ... + @final def asfreq( self, freq, @@ -1753,18 +1761,21 @@ class DataFrame(NDFrame, OpsMixin, _GetItemHack): normalize: _bool = ..., fill_value: Scalar | None = ..., ) -> Self: ... + @final def astype( self, dtype: AstypeArg | Mapping[Any, Dtype] | Series, copy: _bool = ..., errors: IgnoreRaise = ..., ) -> Self: ... + @final def at_time( self, time: _str | dt.time, asof: _bool = ..., axis: Axis | None = ..., ) -> Self: ... + @final def between_time( self, start_time: _str | dt.time, @@ -1859,6 +1870,7 @@ class DataFrame(NDFrame, OpsMixin, _GetItemHack): inplace: Literal[True], **kwargs: Any, ) -> None: ... + @final def copy(self, deep: _bool = ...) -> Self: ... def cummax( self, axis: Axis | None = ..., skipna: _bool = ..., *args: Any, **kwargs: Any @@ -1872,6 +1884,7 @@ class DataFrame(NDFrame, OpsMixin, _GetItemHack): def cumsum( self, axis: Axis | None = ..., skipna: _bool = ..., *args: Any, **kwargs: Any ) -> Self: ... + @final def describe( self, percentiles: list[float] | None = ..., @@ -1892,9 +1905,12 @@ class DataFrame(NDFrame, OpsMixin, _GetItemHack): level: Level | None = ..., fill_value: float | None = ..., ) -> Self: ... + @final def droplevel(self, level: Level | list[Level], axis: Axis = ...) -> Self: ... def eq(self, other, axis: Axis = ..., level: Level | None = ...) -> Self: ... + @final def equals(self, other: Series | DataFrame) -> _bool: ... + @final def ewm( self, com: float | None = ..., @@ -1906,6 +1922,7 @@ class DataFrame(NDFrame, OpsMixin, _GetItemHack): ignore_na: _bool = ..., axis: Axis = ..., ) -> ExponentialMovingWindow[Self]: ... + @final def expanding( self, min_periods: int = ..., @@ -1937,7 +1954,9 @@ class DataFrame(NDFrame, OpsMixin, _GetItemHack): regex: _str | None = ..., axis: Axis | None = ..., ) -> Self: ... + @final def first(self, offset) -> Self: ... + @final def first_valid_index(self) -> Scalar: ... def floordiv( self, @@ -1958,7 +1977,9 @@ class DataFrame(NDFrame, OpsMixin, _GetItemHack): @overload def get(self, key: list[Hashable], default: _T) -> Self | _T: ... def gt(self, other, axis: Axis = ..., level: Level | None = ...) -> Self: ... + @final def head(self, n: int = ...) -> Self: ... + @final def infer_objects(self) -> Self: ... # def info @overload @@ -2000,7 +2021,9 @@ class DataFrame(NDFrame, OpsMixin, _GetItemHack): numeric_only: _bool = ..., **kwargs: Any, ) -> Series: ... + @final def last(self, offset) -> Self: ... + @final def last_valid_index(self) -> Scalar: ... def le(self, other, axis: Axis = ..., level: Level | None = ...) -> Self: ... def lt(self, other, axis: Axis = ..., level: Level | None = ...) -> Self: ... @@ -2088,6 +2111,7 @@ class DataFrame(NDFrame, OpsMixin, _GetItemHack): fill_value: float | None = ..., ) -> Self: ... def ne(self, other, axis: Axis = ..., level: Level | None = ...) -> Self: ... + @final def pct_change( self, periods: int = ..., @@ -2130,6 +2154,7 @@ class DataFrame(NDFrame, OpsMixin, _GetItemHack): level: Level | None = ..., fill_value: float | None = ..., ) -> Self: ... + @final def rank( self, axis: Axis = ..., @@ -2146,6 +2171,7 @@ class DataFrame(NDFrame, OpsMixin, _GetItemHack): level: Level | None = ..., fill_value: float | None = ..., ) -> Self: ... + @final def reindex_like( self, other: DataFrame, @@ -2264,7 +2290,7 @@ class DataFrame(NDFrame, OpsMixin, _GetItemHack): level: Level | None = ..., fill_value: float | None = ..., ) -> Self: ... - # sample is missing a weights arg + @final def sample( self, n: int | None = ..., @@ -2294,6 +2320,7 @@ class DataFrame(NDFrame, OpsMixin, _GetItemHack): numeric_only: _bool = ..., **kwargs: Any, ) -> Series: ... + @final def squeeze(self, axis: Axis | None = ...) -> DataFrame | Series | Scalar: ... def std( self, @@ -2327,7 +2354,9 @@ class DataFrame(NDFrame, OpsMixin, _GetItemHack): min_count: int = ..., **kwargs: Any, ) -> Series: ... + @final def swapaxes(self, axis1: Axis, axis2: Axis, copy: _bool = ...) -> Self: ... + @final def tail(self, n: int = ...) -> Self: ... @overload def to_json( @@ -2441,6 +2470,7 @@ class DataFrame(NDFrame, OpsMixin, _GetItemHack): max_colwidth: int | None = ..., encoding: _str | None = ..., ) -> _str: ... + @final def to_xarray(self) -> xr.Dataset: ... def truediv( self, @@ -2449,6 +2479,7 @@ class DataFrame(NDFrame, OpsMixin, _GetItemHack): level: Level | None = ..., fill_value: float | None = ..., ) -> Self: ... + @final def truncate( self, before: dt.date | _str | int | None = ..., @@ -2456,6 +2487,7 @@ class DataFrame(NDFrame, OpsMixin, _GetItemHack): axis: Axis | None = ..., copy: _bool = ..., ) -> Self: ... + @final def tz_convert( self, tz: TimeZones, @@ -2463,6 +2495,7 @@ class DataFrame(NDFrame, OpsMixin, _GetItemHack): level: Level | None = ..., copy: _bool = ..., ) -> Self: ... + @final def tz_localize( self, tz: TimeZones, @@ -2514,7 +2547,9 @@ class DataFrame(NDFrame, OpsMixin, _GetItemHack): level: Level | None = ..., ) -> Self: ... # Move from generic because Series is Generic and it returns Series[bool] there + @final def __invert__(self) -> Self: ... + @final def xs( self, key: Hashable, @@ -2531,6 +2566,7 @@ class DataFrame(NDFrame, OpsMixin, _GetItemHack): ) -> Self: ... def __truediv__(self, other: float | DataFrame | Series | Sequence) -> Self: ... def __rtruediv__(self, other: float | DataFrame | Series | Sequence) -> Self: ... + @final def __bool__(self) -> NoReturn: ... class _PandasNamedTuple(tuple[Any, ...]): diff --git a/pandas-stubs/core/generic.pyi b/pandas-stubs/core/generic.pyi index b0f81b17..04acdb22 100644 --- a/pandas-stubs/core/generic.pyi +++ b/pandas-stubs/core/generic.pyi @@ -67,6 +67,7 @@ from pandas.io.sql import SQLTable class NDFrame(indexing.IndexingMixin): __hash__: ClassVar[None] # type: ignore[assignment] # pyright: ignore[reportIncompatibleMethodOverride] + @final def set_flags( self, *, @@ -84,18 +85,24 @@ class NDFrame(indexing.IndexingMixin): @property def size(self) -> int: ... def equals(self, other: Series) -> _bool: ... + @final def __neg__(self) -> Self: ... + @final def __pos__(self) -> Self: ... + @final def __nonzero__(self) -> None: ... @final def bool(self) -> _bool: ... def __abs__(self) -> Self: ... + @final def __round__(self, decimals: int = ...) -> Self: ... + @final def __contains__(self, key) -> _bool: ... @property def empty(self) -> _bool: ... __array_priority__: int = ... def __array__(self, dtype=...) -> np.ndarray: ... + @final def to_excel( self, excel_writer, @@ -113,6 +120,7 @@ class NDFrame(indexing.IndexingMixin): inf_rep: _str = ..., freeze_panes: tuple[int, int] | None = ..., ) -> None: ... + @final def to_hdf( self, path_or_buf: FilePath | HDFStore, @@ -149,6 +157,7 @@ class NDFrame(indexing.IndexingMixin): storage_options: StorageOptions = ..., **kwargs: Any, ) -> _str: ... + @final def to_sql( self, name: _str, @@ -168,6 +177,7 @@ class NDFrame(indexing.IndexingMixin): | None ) = ..., ) -> int | None: ... + @final def to_pickle( self, path: FilePath | WriteBuffer[bytes], @@ -175,6 +185,7 @@ class NDFrame(indexing.IndexingMixin): protocol: int = ..., storage_options: StorageOptions = ..., ) -> None: ... + @final def to_clipboard( self, excel: _bool = ..., @@ -300,6 +311,7 @@ class NDFrame(indexing.IndexingMixin): errors: OpenFileErrors = ..., storage_options: StorageOptions = ..., ) -> _str: ... + @final def __delitem__(self, idx: Hashable) -> None: ... @overload def drop( @@ -387,10 +399,15 @@ class NDFrame(indexing.IndexingMixin): *args: Any, **kwargs: Any, ) -> T: ... + @final def __finalize__(self, other, method=..., **kwargs) -> Self: ... + @final def __setattr__(self, name: _str, value) -> None: ... + @final def __copy__(self, deep: _bool = ...) -> Self: ... + @final def __deepcopy__(self, memo=...) -> Self: ... + @final def convert_dtypes( self, infer_objects: _bool = ..., diff --git a/pandas-stubs/core/indexes/base.pyi b/pandas-stubs/core/indexes/base.pyi index a6a4d80f..e19e7f0c 100644 --- a/pandas-stubs/core/indexes/base.pyi +++ b/pandas-stubs/core/indexes/base.pyi @@ -276,12 +276,14 @@ class Index(IndexOpsMixin[S1]): Index[_str], Index[type[object]], ]: ... + @final def is_(self, other) -> bool: ... def __len__(self) -> int: ... def __array__(self, dtype=...) -> np.ndarray: ... def __array_wrap__(self, result, context=...): ... @property def dtype(self) -> DtypeObj: ... + @final def ravel(self, order: _str = ...): ... def view(self, cls=...): ... def astype(self, dtype: DtypeArg, copy: bool = ...) -> Index: ... @@ -290,7 +292,9 @@ class Index(IndexOpsMixin[S1]): ): ... def repeat(self, repeats, axis=...): ... def copy(self, name: Hashable = ..., deep: bool = ...) -> Self: ... + @final def __copy__(self, **kwargs): ... + @final def __deepcopy__(self, memo=...): ... def format( self, name: bool = ..., formatter: Callable | None = ..., na_rep: _str = ... @@ -328,8 +332,10 @@ class Index(IndexOpsMixin[S1]): def __reduce__(self): ... @property def hasnans(self) -> bool: ... + @final def isna(self): ... isnull = ... + @final def notna(self): ... notnull = ... def fillna(self, value=...): ... @@ -344,6 +350,7 @@ class Index(IndexOpsMixin[S1]): def __xor__(self, other: Never) -> Never: ... def __rxor__(self, other: Never) -> Never: ... def __neg__(self) -> Self: ... + @final def __nonzero__(self) -> None: ... __bool__ = ... def union(self, other: list[HashableT] | Index, sort=...) -> Index: ... @@ -380,6 +387,7 @@ class Index(IndexOpsMixin[S1]): def memory_usage(self, deep: bool = ...): ... def where(self, cond, other=...): ... def __contains__(self, key) -> bool: ... + @final def __setitem__(self, key, value) -> None: ... @overload def __getitem__( @@ -391,7 +399,9 @@ class Index(IndexOpsMixin[S1]): def append(self, other): ... def putmask(self, mask, value): ... def equals(self, other) -> bool: ... + @final def identical(self, other) -> bool: ... + @final def asof(self, label): ... def asof_locs(self, where, mask): ... def sort_values( @@ -402,9 +412,11 @@ class Index(IndexOpsMixin[S1]): na_position: NaPosition = ..., key: Callable[[Index], Index] | None = None, ): ... + @final def sort(self, *args, **kwargs) -> None: ... def argsort(self, *args, **kwargs): ... def get_indexer_non_unique(self, target): ... + @final def get_indexer_for(self, target, **kwargs): ... @final def groupby(self, values) -> dict[Hashable, np.ndarray]: ... diff --git a/pandas-stubs/core/indexes/category.pyi b/pandas-stubs/core/indexes/category.pyi index 19dd550e..324ff9ea 100644 --- a/pandas-stubs/core/indexes/category.pyi +++ b/pandas-stubs/core/indexes/category.pyi @@ -2,7 +2,10 @@ from collections.abc import ( Hashable, Iterable, ) -from typing import Literal +from typing import ( + Literal, + final, +) import numpy as np from pandas.core import accessor @@ -46,8 +49,10 @@ class CategoricalIndex(ExtensionIndex[S1], accessor.PandasDelegate): def is_monotonic_decreasing(self) -> bool: ... def unique(self, level=...): ... def duplicated(self, keep: Literal["first", "last", False] = ...): ... + @final def where(self, cond, other=...): ... def reindex(self, target, method=..., level=..., limit=..., tolerance=...): ... + @final def get_indexer(self, target, method=..., limit=..., tolerance=...): ... def get_indexer_non_unique(self, target): ... def delete(self, loc): ... diff --git a/pandas-stubs/core/indexes/datetimes.pyi b/pandas-stubs/core/indexes/datetimes.pyi index 4aa810c2..40a7102c 100644 --- a/pandas-stubs/core/indexes/datetimes.pyi +++ b/pandas-stubs/core/indexes/datetimes.pyi @@ -7,7 +7,10 @@ from datetime import ( timedelta, tzinfo as _tzinfo, ) -from typing import overload +from typing import ( + final, + overload, +) import numpy as np from pandas import ( @@ -72,6 +75,7 @@ class DatetimeIndex(DatetimeTimedeltaMixin[Timestamp], DatetimeIndexProperties): def __sub__( self, other: datetime | Timestamp | DatetimeIndex ) -> TimedeltaIndex: ... + @final def to_series(self, index=..., name: Hashable = ...) -> TimestampSeries: ... def snap(self, freq: str = ...): ... def slice_indexer(self, start=..., end=..., step=...): ... diff --git a/pandas-stubs/core/indexes/interval.pyi b/pandas-stubs/core/indexes/interval.pyi index 760b8807..026c4f2a 100644 --- a/pandas-stubs/core/indexes/interval.pyi +++ b/pandas-stubs/core/indexes/interval.pyi @@ -5,6 +5,7 @@ from collections.abc import ( import datetime as dt from typing import ( Literal, + final, overload, ) @@ -228,6 +229,7 @@ class IntervalIndex(ExtensionIndex[IntervalT], IntervalMixin): method: FillnaOptions | Literal["nearest"] | None = ..., tolerance=..., ) -> int | slice | npt.NDArray[np.bool_]: ... + @final def get_indexer( self, target: Index, diff --git a/pandas-stubs/core/indexes/multi.pyi b/pandas-stubs/core/indexes/multi.pyi index aae164ef..e1af32ea 100644 --- a/pandas-stubs/core/indexes/multi.pyi +++ b/pandas-stubs/core/indexes/multi.pyi @@ -4,7 +4,10 @@ from collections.abc import ( Iterable, Sequence, ) -from typing import overload +from typing import ( + final, + overload, +) import numpy as np import pandas as pd @@ -135,6 +138,7 @@ class MultiIndex(Index): def append(self, other): ... def argsort(self, *args, **kwargs): ... def repeat(self, repeats, axis=...): ... + @final def where(self, cond, other=...) -> None: ... def drop(self, codes, level=..., errors: str = ...) -> Self: ... # type: ignore[override] # pyright: ignore[reportIncompatibleMethodOverride] def swaplevel(self, i: int = ..., j: int = ...): ... @@ -146,6 +150,7 @@ class MultiIndex(Index): sort_remaining: bool = ..., na_position: NaPosition = ..., ): ... + @final def get_indexer(self, target, method=..., limit=..., tolerance=...): ... def get_indexer_non_unique(self, target): ... def reindex(self, target, method=..., level=..., limit=..., tolerance=...): ... @@ -157,10 +162,13 @@ class MultiIndex(Index): def truncate(self, before=..., after=...): ... def equals(self, other) -> bool: ... def equal_levels(self, other): ... + @final def union(self, other, sort=...): ... # pyrefly: ignore + @final def intersection( # pyright: ignore[reportIncompatibleMethodOverride] self, other: list | Self, sort: bool = ... ): ... + @final def difference(self, other, sort=...): ... def astype(self, dtype: DtypeArg, copy: bool = ...) -> Self: ... def insert(self, loc, item): ... diff --git a/pandas-stubs/core/indexes/period.pyi b/pandas-stubs/core/indexes/period.pyi index ae16b70b..8857677c 100644 --- a/pandas-stubs/core/indexes/period.pyi +++ b/pandas-stubs/core/indexes/period.pyi @@ -1,6 +1,9 @@ from collections.abc import Hashable import datetime -from typing import overload +from typing import ( + final, + overload, +) import numpy as np import pandas as pd @@ -51,6 +54,7 @@ class PeriodIndex(DatetimeIndexOpsMixin[pd.Period], PeriodIndexFieldOps): self, other: NaTType ) -> NaTType: ... def __array__(self, dtype=...) -> np.ndarray: ... + @final def __array_wrap__(self, result, context=...): ... def asof_locs(self, where, mask): ... def astype(self, dtype, copy: bool = ...): ... @@ -59,9 +63,11 @@ class PeriodIndex(DatetimeIndexOpsMixin[pd.Period], PeriodIndexFieldOps): def is_full(self) -> bool: ... @property def inferred_type(self) -> str: ... + @final def get_indexer(self, target, method=..., limit=..., tolerance=...): ... def get_indexer_non_unique(self, target): ... def insert(self, loc, item): ... + @final def join( self, other, @@ -71,6 +77,7 @@ class PeriodIndex(DatetimeIndexOpsMixin[pd.Period], PeriodIndexFieldOps): return_indexers: bool = ..., sort: bool = ..., ): ... + @final def difference(self, other, sort=...): ... def memory_usage(self, deep: bool = ...): ... @property diff --git a/pandas-stubs/core/indexes/range.pyi b/pandas-stubs/core/indexes/range.pyi index 1576fc1d..580bed26 100644 --- a/pandas-stubs/core/indexes/range.pyi +++ b/pandas-stubs/core/indexes/range.pyi @@ -2,7 +2,10 @@ from collections.abc import ( Hashable, Sequence, ) -from typing import overload +from typing import ( + final, + overload, +) import numpy as np from pandas.core.indexes.base import Index @@ -47,6 +50,7 @@ class RangeIndex(Index[int]): @property def has_duplicates(self) -> bool: ... def __contains__(self, key: int | np.integer) -> bool: ... + @final def get_indexer(self, target, method=..., limit=..., tolerance=...): ... def tolist(self): ... def copy(self, name: Hashable = ..., deep: bool = ..., dtype=..., **kwargs): ... @@ -57,6 +61,7 @@ class RangeIndex(Index[int]): self, sort: bool = ..., use_na_sentinel: bool = ... ) -> tuple[npt.NDArray[np.intp], RangeIndex]: ... def equals(self, other): ... + @final def join( self, other, @@ -72,6 +77,7 @@ class RangeIndex(Index[int]): def __floordiv__(self, other): ... def all(self) -> bool: ... def any(self) -> bool: ... + @final def union( # pyrefly: ignore self, other: list[HashableT] | Index, sort=... ) -> Index | Index[int] | RangeIndex: ... diff --git a/pandas-stubs/core/indexes/timedeltas.pyi b/pandas-stubs/core/indexes/timedeltas.pyi index 6cb94df7..cc426586 100644 --- a/pandas-stubs/core/indexes/timedeltas.pyi +++ b/pandas-stubs/core/indexes/timedeltas.pyi @@ -5,6 +5,7 @@ from collections.abc import ( import datetime as dt from typing import ( Literal, + final, overload, ) @@ -73,6 +74,7 @@ class TimedeltaIndex(DatetimeTimedeltaMixin[Timedelta], TimedeltaIndexProperties def searchsorted(self, value, side: str = ..., sorter=...): ... @property def inferred_type(self) -> str: ... + @final def to_series(self, index=..., name: Hashable = ...) -> TimedeltaSeries: ... def shift(self, periods: int = ..., freq=...) -> Self: ... diff --git a/pandas-stubs/core/resample.pyi b/pandas-stubs/core/resample.pyi index 1216bb97..b0a91416 100644 --- a/pandas-stubs/core/resample.pyi +++ b/pandas-stubs/core/resample.pyi @@ -5,6 +5,7 @@ from collections.abc import ( ) from typing import ( Literal, + final, overload, ) @@ -82,8 +83,11 @@ class Resampler(BaseGroupBy[NDFrameT]): def transform( self: Resampler[DataFrame], arg: Callable[[Series], Series[S1]], *args, **kwargs ) -> DataFrame: ... + @final def ffill(self, limit: int | None = ...) -> NDFrameT: ... + @final def nearest(self, limit: int | None = ...) -> NDFrameT: ... + @final def bfill(self, limit: int | None = ...) -> NDFrameT: ... @overload def interpolate( @@ -109,32 +113,47 @@ class Resampler(BaseGroupBy[NDFrameT]): limit_area: Literal["inside", "outside"] | None = ..., **kwargs, ) -> NDFrameT: ... + @final def asfreq(self, fill_value: Scalar | None = ...) -> NDFrameT: ... + @final def sum(self, numeric_only: bool = ..., min_count: int = ...) -> NDFrameT: ... + @final def prod(self, numeric_only: bool = ..., min_count: int = ...) -> NDFrameT: ... + @final def min(self, numeric_only: bool = ..., min_count: int = ...) -> NDFrameT: ... + @final def max(self, numeric_only: bool = ..., min_count: int = ...) -> NDFrameT: ... + @final def first( self, numeric_only: bool = ..., min_count: int = ..., skipna: bool = ... ) -> NDFrameT: ... + @final def last( self, numeric_only: bool = ..., min_count: int = ..., skipna: bool = ... ) -> NDFrameT: ... + @final def median(self, numeric_only: bool = ...) -> NDFrameT: ... + @final def mean(self, numeric_only: bool = ...) -> NDFrameT: ... + @final def std(self, ddof: int = ..., numeric_only: bool = ...) -> NDFrameT: ... + @final def var(self, ddof: int = ..., numeric_only: bool = ...) -> NDFrameT: ... + @final def sem(self, ddof: int = ..., numeric_only: bool = ...) -> NDFrameT: ... + @final def ohlc(self) -> DataFrame: ... @overload def nunique(self: Resampler[Series]) -> Series[int]: ... @overload def nunique(self: Resampler[DataFrame]) -> DataFrame: ... + @final def size(self) -> Series[int]: ... @overload def count(self: Resampler[Series]) -> Series[int]: ... @overload def count(self: Resampler[DataFrame]) -> DataFrame: ... + @final def quantile( self, q: float | list[float] | npt.NDArray[np.double] | Series[float] = ..., @@ -152,6 +171,7 @@ class DatetimeIndexResampler(Resampler[NDFrameT]): ... class DatetimeIndexResamplerGroupby( _GroupByMixin[NDFrameT], DatetimeIndexResampler[NDFrameT] ): + @final def __getattr__(self, attr: str) -> Self: ... # type: ignore[override] # pyright: ignore[reportIncompatibleMethodOverride] class PeriodIndexResampler(DatetimeIndexResampler[NDFrameT]): ... @@ -159,6 +179,7 @@ class PeriodIndexResampler(DatetimeIndexResampler[NDFrameT]): ... class PeriodIndexResamplerGroupby( _GroupByMixin[NDFrameT], PeriodIndexResampler[NDFrameT] ): + @final def __getattr__(self, attr: str) -> Self: ... # type: ignore[override] # pyright: ignore[reportIncompatibleMethodOverride] class TimedeltaIndexResampler(DatetimeIndexResampler[NDFrameT]): ... @@ -166,6 +187,7 @@ class TimedeltaIndexResampler(DatetimeIndexResampler[NDFrameT]): ... class TimedeltaIndexResamplerGroupby( _GroupByMixin[NDFrameT], TimedeltaIndexResampler[NDFrameT] ): + @final def __getattr__(self, attr: str) -> Self: ... # type: ignore[override] # pyright: ignore[reportIncompatibleMethodOverride] class TimeGrouper(Grouper): diff --git a/pandas-stubs/core/series.pyi b/pandas-stubs/core/series.pyi index 57fe5f04..6f63d77a 100644 --- a/pandas-stubs/core/series.pyi +++ b/pandas-stubs/core/series.pyi @@ -25,6 +25,7 @@ from typing import ( Generic, Literal, NoReturn, + final, overload, ) @@ -452,12 +453,14 @@ class Series(IndexOpsMixin[S1], NDFrame): def ravel(self, order: _str = ...) -> np.ndarray: ... def __len__(self) -> int: ... def view(self, dtype=...) -> Series[S1]: ... + @final def __array_ufunc__( self, ufunc: Callable, method: _str, *inputs: Any, **kwargs: Any ): ... def __array__(self, dtype=...) -> np.ndarray: ... @property def axes(self) -> list: ... + @final def __getattr__(self, name: _str) -> S1: ... @overload def __getitem__( @@ -611,6 +614,7 @@ class Series(IndexOpsMixin[S1], NDFrame): indent: int | None = ..., mode: Literal["w"] = ..., ) -> _str: ... + @final def to_xarray(self) -> xr.DataArray: ... def items(self) -> Iterator[tuple[Hashable, S1]]: ... def keys(self) -> Index: ... @@ -1023,6 +1027,7 @@ class Series(IndexOpsMixin[S1], NDFrame): args: tuple = ..., **kwargs: Any, ) -> DataFrame: ... + @final def align( self, other: DataFrame | Series, @@ -1076,6 +1081,7 @@ class Series(IndexOpsMixin[S1], NDFrame): level: Level | None = ..., errors: IgnoreRaise = ..., ) -> Self: ... + @final def reindex_like( self, other: Series[S1], @@ -1203,14 +1209,20 @@ class Series(IndexOpsMixin[S1], NDFrame): backend: _str | None = ..., **kwargs: Any, ) -> SubplotBase: ... + @final def swapaxes( self, axis1: AxisIndex, axis2: AxisIndex, copy: _bool = ... ) -> Series[S1]: ... + @final def droplevel(self, level: Level | list[Level], axis: AxisIndex = ...) -> Self: ... def pop(self, item: Hashable) -> S1: ... + @final def squeeze(self) -> Series[S1] | Scalar: ... + @final def __abs__(self) -> Series[S1]: ... + @final def add_prefix(self, prefix: _str, axis: AxisIndex | None = ...) -> Series[S1]: ... + @final def add_suffix(self, suffix: _str, axis: AxisIndex | None = ...) -> Series[S1]: ... def reindex( self, @@ -1229,8 +1241,11 @@ class Series(IndexOpsMixin[S1], NDFrame): regex: _str | None = ..., axis: AxisIndex | None = ..., ) -> Series[S1]: ... + @final def head(self, n: int = ...) -> Series[S1]: ... + @final def tail(self, n: int = ...) -> Series[S1]: ... + @final def sample( self, n: int | None = ..., @@ -1311,7 +1326,9 @@ class Series(IndexOpsMixin[S1], NDFrame): copy: _bool = ..., errors: IgnoreRaise = ..., ) -> Series: ... + @final def copy(self, deep: _bool = ...) -> Series[S1]: ... + @final def infer_objects(self) -> Series[S1]: ... @overload def ffill( @@ -1373,6 +1390,7 @@ class Series(IndexOpsMixin[S1], NDFrame): limit_area: Literal["inside", "outside"] | None = ..., **kwargs: Any, ) -> Series[S1]: ... + @final def asof( self, where: Scalar | Sequence[Scalar], @@ -1408,6 +1426,7 @@ class Series(IndexOpsMixin[S1], NDFrame): inplace: Literal[False] = ..., **kwargs: Any, ) -> Series[S1]: ... + @final def asfreq( self, freq, @@ -1416,20 +1435,25 @@ class Series(IndexOpsMixin[S1], NDFrame): normalize: _bool = ..., fill_value: Scalar | None = ..., ) -> Series[S1]: ... + @final def at_time( self, time: _str | time, asof: _bool = ..., axis: AxisIndex | None = ..., ) -> Series[S1]: ... + @final def between_time( self, start_time: _str | time, end_time: _str | time, axis: AxisIndex | None = ..., ) -> Series[S1]: ... + @final def first(self, offset) -> Series[S1]: ... + @final def last(self, offset) -> Series[S1]: ... + @final def rank( self, axis: AxisIndex = ..., @@ -1514,6 +1538,7 @@ class Series(IndexOpsMixin[S1], NDFrame): ], ], ) -> Series: ... + @final def truncate( self, before: date | _str | int | None = ..., @@ -1521,6 +1546,7 @@ class Series(IndexOpsMixin[S1], NDFrame): axis: AxisIndex | None = ..., copy: _bool = ..., ) -> Series[S1]: ... + @final def tz_convert( self, tz: TimeZones, @@ -1528,6 +1554,7 @@ class Series(IndexOpsMixin[S1], NDFrame): level: Level | None = ..., copy: _bool = ..., ) -> Series[S1]: ... + @final def tz_localize( self, tz: TimeZones, @@ -1537,13 +1564,16 @@ class Series(IndexOpsMixin[S1], NDFrame): ambiguous: TimeAmbiguous = ..., nonexistent: _str = ..., ) -> Series[S1]: ... + @final def abs(self) -> Series[S1]: ... + @final def describe( self, percentiles: list[float] | None = ..., include: Literal["all"] | list[S1] | None = ..., exclude: S1 | list[S1] | None = ..., ) -> Series[S1]: ... + @final def pct_change( self, periods: int = ..., @@ -1552,7 +1582,9 @@ class Series(IndexOpsMixin[S1], NDFrame): *, fill_value: Scalar | NAType | None = ..., ) -> Series[float]: ... + @final def first_valid_index(self) -> Scalar: ... + @final def last_valid_index(self) -> Scalar: ... @overload def value_counts( # pyrefly: ignore @@ -1572,6 +1604,7 @@ class Series(IndexOpsMixin[S1], NDFrame): bins: int | None = ..., dropna: _bool = ..., ) -> Series[float]: ... + @final @property def T(self) -> Self: ... # The rest of these were left over from the old @@ -1688,6 +1721,7 @@ class Series(IndexOpsMixin[S1], NDFrame): ) -> Series[bool]: ... @overload def __xor__(self, other: int | np_ndarray_anyint | Series[int]) -> Series[int]: ... + @final def __invert__(self) -> Series[bool]: ... # properties # @property @@ -1774,6 +1808,7 @@ class Series(IndexOpsMixin[S1], NDFrame): fill_value: float | None = ..., axis: AxisIndex = ..., ) -> Series[_bool]: ... + @final def ewm( self, com: float | None = ..., @@ -1784,6 +1819,7 @@ class Series(IndexOpsMixin[S1], NDFrame): adjust: _bool = ..., ignore_na: _bool = ..., ) -> ExponentialMovingWindow[Series]: ... + @final def expanding( self, min_periods: int = ..., @@ -1810,6 +1846,7 @@ class Series(IndexOpsMixin[S1], NDFrame): fill_value: float | None = ..., axis: AxisIndex = ..., ) -> Series[_bool]: ... + @final def item(self) -> S1: ... def kurt( self, @@ -1910,6 +1947,7 @@ class Series(IndexOpsMixin[S1], NDFrame): fill_value: float | None = ..., axis: AxisIndex = ..., ) -> Series[_bool]: ... + @final def nunique(self, dropna: _bool = ...) -> int: ... def pow( self, @@ -2101,6 +2139,7 @@ class Series(IndexOpsMixin[S1], NDFrame): **kwargs: Any, ) -> S1: ... def to_list(self) -> list[S1]: ... + @final def to_numpy( self, dtype: npt.DTypeLike | None = ..., @@ -2165,6 +2204,7 @@ class Series(IndexOpsMixin[S1], NDFrame): ) -> Self: ... def set_axis(self, labels, *, axis: Axis = ..., copy: _bool = ...) -> Self: ... def __iter__(self) -> Iterator[S1]: ... + @final def xs( self, key: Hashable, @@ -2172,6 +2212,7 @@ class Series(IndexOpsMixin[S1], NDFrame): level: Level | None = ..., drop_level: _bool = ..., ) -> Self: ... + @final def __bool__(self) -> NoReturn: ... class TimestampSeries(Series[Timestamp]): diff --git a/pandas-stubs/io/common.pyi b/pandas-stubs/io/common.pyi index ede6e40b..335912b3 100644 --- a/pandas-stubs/io/common.pyi +++ b/pandas-stubs/io/common.pyi @@ -1,3 +1,4 @@ +from types import TracebackType from typing import ( IO, AnyStr, @@ -9,9 +10,14 @@ from pandas._typing import CompressionDict class IOHandles(Generic[AnyStr]): handle: IO[AnyStr] compression: CompressionDict - created_handles: list[IO[AnyStr]] - is_wrapped: bool + created_handles: list[IO[AnyStr]] = ... + is_wrapped: bool = ... def close(self) -> None: ... def __enter__(self) -> IOHandles[AnyStr]: ... - def __exit__(self, *args: object) -> None: ... + def __exit__( + self, + exc_type: type[BaseException] | None, + exc_value: BaseException | None, + traceback: TracebackType | None, + ) -> None: ... def __init__(self, handle, compression, created_handles, is_wrapped) -> None: ... diff --git a/pandas-stubs/io/pytables.pyi b/pandas-stubs/io/pytables.pyi index 9d4107e2..db06bac0 100644 --- a/pandas-stubs/io/pytables.pyi +++ b/pandas-stubs/io/pytables.pyi @@ -122,7 +122,7 @@ class HDFStore: exc_value: BaseException | None, traceback: TracebackType | None, ) -> None: ... - def keys(self) -> list[str]: ... + def keys(self, include=...) -> list[str]: ... def __iter__(self) -> Iterator[str]: ... def open(self, mode: Literal["a", "w", "r", "r+"] = ..., **kwargs) -> None: ... def close(self) -> None: ...