diff --git a/pandas-stubs/_config/config.pyi b/pandas-stubs/_config/config.pyi index d848377a0..48740eeff 100644 --- a/pandas-stubs/_config/config.pyi +++ b/pandas-stubs/_config/config.pyi @@ -47,7 +47,6 @@ class DisplayUnicode(DictWrapper): class Display(DictWrapper): chop_threshold: int | None colheader_justify: str - column_space: int date_dayfirst: bool date_yearfirst: bool encoding: str diff --git a/pandas-stubs/core/algorithms.pyi b/pandas-stubs/core/algorithms.pyi index 72e907cc8..5663a0c77 100644 --- a/pandas-stubs/core/algorithms.pyi +++ b/pandas-stubs/core/algorithms.pyi @@ -26,7 +26,8 @@ def unique(values: ExtensionArray) -> ExtensionArray: ... def factorize( values: Any, sort: bool = ..., - na_sentinel: int | None = ..., + # Not actually positional-only, used to handle deprecations in 1.5.0 + *, use_na_sentinel: bool = ..., size_hint: int | None = ..., ) -> tuple[np.ndarray, np.ndarray | Index]: ... diff --git a/pandas-stubs/core/arrays/base.pyi b/pandas-stubs/core/arrays/base.pyi index b761d7d95..0d781377f 100644 --- a/pandas-stubs/core/arrays/base.pyi +++ b/pandas-stubs/core/arrays/base.pyi @@ -33,7 +33,7 @@ class ExtensionArray: def astype(self, dtype, copy: bool = ...): ... def isna(self) -> ArrayLike: ... def argsort( - self, ascending: bool = ..., kind: str = ..., *args, **kwargs + self, *, ascending: bool = ..., kind: str = ..., **kwargs ) -> np.ndarray: ... def fillna(self, value=..., method=..., limit=...): ... def dropna(self): ... diff --git a/pandas-stubs/core/arrays/categorical.pyi b/pandas-stubs/core/arrays/categorical.pyi index 510cefc3f..9b5f86985 100644 --- a/pandas-stubs/core/arrays/categorical.pyi +++ b/pandas-stubs/core/arrays/categorical.pyi @@ -42,8 +42,6 @@ class Categorical(ExtensionArray, PandasObject): ) -> None: ... @property def categories(self): ... - @categories.setter - def categories(self, categories) -> None: ... @property def ordered(self) -> Ordered: ... @property @@ -64,22 +62,9 @@ class Categorical(ExtensionArray, PandasObject): ) -> Categorical: ... @property def codes(self) -> np_ndarray_int: ... - @overload - def set_ordered(self, value, inplace: Literal[True]) -> None: ... - @overload - def set_ordered(self, value, inplace: Literal[False] = ...) -> Categorical: ... - @overload - def set_ordered(self, value, inplace: bool = ...) -> Categorical | None: ... - @overload - def as_ordered(self, inplace: Literal[True]) -> None: ... - @overload - def as_ordered(self, inplace: Literal[False] = ...) -> Categorical: ... - @overload - def as_ordered(self, inplace: bool = ...) -> Categorical | None: ... - @overload - def as_unordered(self, inplace: Literal[True]) -> None: ... - @overload - def as_unordered(self, inplace: Literal[False] = ...) -> Categorical: ... + def set_ordered(self, value) -> Categorical: ... + def as_ordered(self) -> Categorical: ... + def as_unordered(self) -> Categorical: ... @overload def set_categories( self, new_categories, ordered=..., rename: bool = ..., *, inplace: Literal[True] diff --git a/pandas-stubs/core/base.pyi b/pandas-stubs/core/base.pyi index 31ec984af..81d019f19 100644 --- a/pandas-stubs/core/base.pyi +++ b/pandas-stubs/core/base.pyi @@ -17,10 +17,6 @@ from pandas._typing import ( npt, ) -# TODO: These two moved to pandas.errors after switch to 1.5.x -class DataError(Exception): ... -class SpecificationError(Exception): ... - class PandasObject(DirNamesMixin): def __sizeof__(self) -> int: ... @@ -80,13 +76,11 @@ class IndexOpsMixin: @property def is_unique(self) -> bool: ... @property - def is_monotonic(self) -> bool: ... - @property def is_monotonic_decreasing(self) -> bool: ... @property def is_monotonic_increasing(self) -> bool: ... def factorize( - self, sort: bool = ..., na_sentinel: int = ... + self, sort: bool = ... ) -> tuple[np.ndarray, np.ndarray | Index | Categorical]: ... def searchsorted( self, value, side: Literal["left", "right"] = ..., sorter=... diff --git a/pandas-stubs/core/common.pyi b/pandas-stubs/core/common.pyi index 926699150..61050a898 100644 --- a/pandas-stubs/core/common.pyi +++ b/pandas-stubs/core/common.pyi @@ -5,10 +5,6 @@ from typing import ( from pandas._typing import T -# TODO: Remove from here after 1.5.x is target, moved to pandas.errors -class SettingWithCopyError(ValueError): ... -class SettingWithCopyWarning(Warning): ... - def flatten(line) -> None: ... def consensus_name_attr(objs): ... def is_bool_indexer(key) -> bool: ... diff --git a/pandas-stubs/core/computation/engines.pyi b/pandas-stubs/core/computation/engines.pyi index c9c4dfc96..f2a162329 100644 --- a/pandas-stubs/core/computation/engines.pyi +++ b/pandas-stubs/core/computation/engines.pyi @@ -1,8 +1,5 @@ import abc -# TODO: Remove from here after 1.5.x, moved to pandas.errors -class NumExprClobberingError(NameError): ... - class AbstractEngine(metaclass=abc.ABCMeta): has_neg_frac: bool = ... expr = ... diff --git a/pandas-stubs/core/frame.pyi b/pandas-stubs/core/frame.pyi index 9717cb610..4859f2285 100644 --- a/pandas-stubs/core/frame.pyi +++ b/pandas-stubs/core/frame.pyi @@ -208,7 +208,6 @@ class DataFrame(NDFrame, OpsMixin): @property def style(self) -> Styler: ... def items(self) -> Iterable[tuple[Hashable, Series]]: ... - def iteritems(self) -> Iterable[tuple[Label, Series]]: ... def iterrows(self) -> Iterable[tuple[Label, Series]]: ... def itertuples(self, index: _bool = ..., name: _str | None = ...): ... def __len__(self) -> int: ... @@ -294,6 +293,7 @@ class DataFrame(NDFrame, OpsMixin): def to_stata( self, path: FilePath | WriteBuffer[bytes], + *, convert_dates: dict[HashableT, StataDateFormat] | None = ..., write_index: _bool = ..., byteorder: Literal["<", ">", "little", "big"] | None = ..., @@ -304,7 +304,6 @@ class DataFrame(NDFrame, OpsMixin): convert_strl: list[HashableT] | None = ..., compression: CompressionOptions = ..., storage_options: StorageOptions = ..., - *, value_labels: dict[Hashable, dict[float, str]] | None = ..., ) -> None: ... def to_feather(self, path: FilePath | WriteBuffer[bytes], **kwargs) -> None: ... @@ -1020,6 +1019,7 @@ class DataFrame(NDFrame, OpsMixin): ) -> _DataFrameGroupByNonScalar: ... def pivot( self, + *, index: IndexLabel = ..., columns: IndexLabel = ..., values: IndexLabel = ..., @@ -1126,14 +1126,18 @@ class DataFrame(NDFrame, OpsMixin): self, method: Literal["pearson", "kendall", "spearman"] = ..., min_periods: int = ..., + numeric_only: _bool = ..., + ) -> DataFrame: ... + def cov( + self, min_periods: int | None = ..., ddof: int = ..., numeric_only: _bool = ... ) -> DataFrame: ... - def cov(self, min_periods: int | None = ..., ddof: int = ...) -> DataFrame: ... def corrwith( self, other: DataFrame | Series, axis: AxisType | None = ..., drop: _bool = ..., method: Literal["pearson", "kendall", "spearman"] = ..., + numeric_only: _bool = ..., ) -> Series: ... @overload def count( @@ -1144,8 +1148,12 @@ class DataFrame(NDFrame, OpsMixin): self, axis: AxisType = ..., level: None = ..., numeric_only: _bool = ... ) -> Series: ... def nunique(self, axis: AxisType = ..., dropna: bool = ...) -> Series: ... - def idxmax(self, axis: AxisType = ..., skipna: _bool = ...) -> Series: ... - def idxmin(self, axis: AxisType = ..., skipna: _bool = ...) -> Series: ... + def idxmax( + self, axis: AxisType = ..., skipna: _bool = ..., numeric_only: _bool = ... + ) -> Series: ... + def idxmin( + self, axis: AxisType = ..., skipna: _bool = ..., numeric_only: _bool = ... + ) -> Series: ... @overload def mode( self, @@ -1298,6 +1306,7 @@ class DataFrame(NDFrame, OpsMixin): @overload def any( self, + *, axis: None, bool_only: _bool | None = ..., skipna: _bool = ..., @@ -1306,6 +1315,7 @@ class DataFrame(NDFrame, OpsMixin): @overload def any( self, + *, axis: AxisType = ..., bool_only: _bool | None = ..., skipna: _bool = ..., @@ -1523,7 +1533,7 @@ class DataFrame(NDFrame, OpsMixin): axis: AxisType | None = ..., skipna: _bool | None = ..., level: None = ..., - numeric_only: _bool | None = ..., + numeric_only: _bool = ..., **kwargs, ) -> Series: ... def kurtosis( @@ -1531,7 +1541,7 @@ class DataFrame(NDFrame, OpsMixin): axis: AxisType | None = ..., skipna: _bool | None = ..., level: None = ..., - numeric_only: _bool | None = ..., + numeric_only: _bool = ..., **kwargs, ) -> Series: ... def last(self, offset) -> DataFrame: ... @@ -1542,22 +1552,6 @@ class DataFrame(NDFrame, OpsMixin): def lt( self, other, axis: AxisType = ..., level: Level | None = ... ) -> DataFrame: ... - @overload - def mad( - self, - axis: AxisType | None = ..., - skipna: _bool | None = ..., - level: None = ..., - ) -> Series: ... - @overload - def mad( - self, - axis: AxisType | None = ..., - skipna: _bool | None = ..., - *, - level: Level, - **kwargs, - ) -> DataFrame: ... def mask( self, cond: Series | DataFrame | np.ndarray, @@ -1565,7 +1559,7 @@ class DataFrame(NDFrame, OpsMixin): inplace: _bool = ..., axis: AxisType | None = ..., level: Level | None = ..., - errors: _str = ..., + *, # Not actually positional-only, but needed due to depr in 1.5.0 try_cast: _bool = ..., ) -> DataFrame: ... def max( @@ -1573,7 +1567,7 @@ class DataFrame(NDFrame, OpsMixin): axis: AxisType | None = ..., skipna: _bool | None = ..., level: None = ..., - numeric_only: _bool | None = ..., + numeric_only: _bool = ..., **kwargs, ) -> Series: ... def mean( @@ -1581,7 +1575,7 @@ class DataFrame(NDFrame, OpsMixin): axis: AxisType | None = ..., skipna: _bool | None = ..., level: None = ..., - numeric_only: _bool | None = ..., + numeric_only: _bool = ..., **kwargs, ) -> Series: ... def median( @@ -1589,7 +1583,7 @@ class DataFrame(NDFrame, OpsMixin): axis: AxisType | None = ..., skipna: _bool | None = ..., level: None = ..., - numeric_only: _bool | None = ..., + numeric_only: _bool = ..., **kwargs, ) -> Series: ... def min( @@ -1597,7 +1591,7 @@ class DataFrame(NDFrame, OpsMixin): axis: AxisType | None = ..., skipna: _bool | None = ..., level: None = ..., - numeric_only: _bool | None = ..., + numeric_only: _bool = ..., **kwargs, ) -> Series: ... def mod( @@ -1651,7 +1645,7 @@ class DataFrame(NDFrame, OpsMixin): axis: AxisType | None = ..., skipna: _bool | None = ..., level: None = ..., - numeric_only: _bool | None = ..., + numeric_only: _bool = ..., min_count: int = ..., **kwargs, ) -> Series: ... @@ -1660,7 +1654,7 @@ class DataFrame(NDFrame, OpsMixin): axis: AxisType | None = ..., skipna: _bool = ..., level: None = ..., - numeric_only: _bool | None = ..., + numeric_only: _bool = ..., min_count: int = ..., **kwargs, ) -> Series: ... @@ -1830,32 +1824,17 @@ class DataFrame(NDFrame, OpsMixin): skipna: _bool | None = ..., level: None = ..., ddof: int = ..., - numeric_only: _bool | None = ..., + numeric_only: _bool = ..., **kwargs, ) -> Series: ... - @overload - def set_axis( - self, labels, inplace: Literal[True], axis: AxisType = ... - ) -> None: ... - @overload - def set_axis( - self, labels, inplace: Literal[False], axis: AxisType = ... - ) -> DataFrame: ... - @overload - def set_axis(self, labels, *, axis: AxisType = ...) -> DataFrame: ... - @overload - def set_axis( - self, - labels, - axis: AxisType = ..., - inplace: _bool | None = ..., - ) -> DataFrame | None: ... + # Not actually positional, but used to handle removal of deprecated + def set_axis(self, labels, *, axis: AxisType, copy: _bool = ...) -> DataFrame: ... def skew( self, axis: AxisType | None = ..., skipna: _bool | None = ..., level: None = ..., - numeric_only: _bool | None = ..., + numeric_only: _bool = ..., **kwargs, ) -> Series: ... def slice_shift(self, periods: int = ..., axis: AxisType = ...) -> DataFrame: ... @@ -1888,7 +1867,7 @@ class DataFrame(NDFrame, OpsMixin): axis: AxisType | None = ..., skipna: _bool | None = ..., level: None = ..., - numeric_only: _bool | None = ..., + numeric_only: _bool = ..., min_count: int = ..., **kwargs, ) -> Series: ... @@ -2024,7 +2003,7 @@ class DataFrame(NDFrame, OpsMixin): skipna: _bool | None = ..., level: None = ..., ddof: int = ..., - numeric_only: _bool | None = ..., + numeric_only: _bool = ..., **kwargs, ) -> Series: ... def where( @@ -2038,7 +2017,7 @@ class DataFrame(NDFrame, OpsMixin): inplace: _bool = ..., axis: AxisType | None = ..., level: Level | None = ..., - errors: _str = ..., + *, # Not actually positional-only, but needed due to depr in 1.5.0 try_cast: _bool = ..., ) -> DataFrame: ... # Move from generic because Series is Generic and it returns Series[bool] there diff --git a/pandas-stubs/core/generic.pyi b/pandas-stubs/core/generic.pyi index e62ebd2c6..17f4025ee 100644 --- a/pandas-stubs/core/generic.pyi +++ b/pandas-stubs/core/generic.pyi @@ -87,14 +87,12 @@ class NDFrame(PandasObject, indexing.IndexingMixin): def __abs__(self) -> NDFrame: ... def __round__(self, decimals: int = ...) -> NDFrame: ... def keys(self): ... - def iteritems(self): ... def __len__(self) -> int: ... def __contains__(self, key) -> _bool: ... @property def empty(self) -> _bool: ... __array_priority__: int = ... def __array__(self, dtype=...) -> np.ndarray: ... - def __array_wrap__(self, result, context=...): ... def to_excel( self, excel_writer, @@ -109,9 +107,9 @@ class NDFrame(PandasObject, indexing.IndexingMixin): startcol: int = ..., engine: _str | None = ..., merge_cells: _bool = ..., - encoding: _str | None = ..., + # Not actually positional, but used to handle removal of deprecated + *, inf_rep: _str = ..., - verbose: _bool = ..., freeze_panes: tuple[int, int] | None = ..., ) -> None: ... def to_hdf( @@ -248,7 +246,7 @@ class NDFrame(PandasObject, indexing.IndexingMixin): compression: CompressionOptions = ..., quoting: CSVQuoting = ..., quotechar: _str = ..., - line_terminator: _str | None = ..., + lineterminator: _str | None = ..., chunksize: int | None = ..., date_format: _str | None = ..., doublequote: _bool = ..., @@ -273,7 +271,7 @@ class NDFrame(PandasObject, indexing.IndexingMixin): compression: CompressionOptions = ..., quoting: CSVQuoting = ..., quotechar: _str = ..., - line_terminator: _str | None = ..., + lineterminator: _str | None = ..., chunksize: int | None = ..., date_format: _str | None = ..., doublequote: _bool = ..., @@ -445,7 +443,7 @@ class NDFrame(PandasObject, indexing.IndexingMixin): inplace: _bool = ..., axis=..., level=..., - errors: _str = ..., + *, # Not actually positional-only, but needed due to depr in 1.5.0 try_cast: _bool = ..., ): ... def mask( @@ -455,7 +453,7 @@ class NDFrame(PandasObject, indexing.IndexingMixin): inplace: _bool = ..., axis=..., level=..., - errors: IgnoreRaise = ..., + *, # Not actually positional-only, but needed due to depr in 1.5.0 try_cast: _bool = ..., ): ... def shift(self, periods=..., freq=..., axis=..., fill_value=...) -> NDFrame: ... diff --git a/pandas-stubs/core/groupby/generic.pyi b/pandas-stubs/core/groupby/generic.pyi index e11354529..f87914f35 100644 --- a/pandas-stubs/core/groupby/generic.pyi +++ b/pandas-stubs/core/groupby/generic.pyi @@ -111,9 +111,9 @@ class SeriesGroupBy(GroupBy, Generic[S1]): engine_kwargs=..., ) -> Series[S1]: ... def prod(self, numeric_only: bool = ..., min_count: int = ...) -> Series[S1]: ... - def sem(self, ddof: int = ...) -> Series[float]: ... - def std(self, ddof: int = ...) -> Series[float]: ... - def var(self, ddof: int = ...) -> Series[float]: ... + def sem(self, ddof: int = ..., numeric_only: bool = ...) -> Series[float]: ... + def std(self, ddof: int = ..., numeric_only: bool = ...) -> Series[float]: ... + def var(self, ddof: int = ..., numeric_only: bool = ...) -> Series[float]: ... def tail(self, n: int = ...) -> Series[S1]: ... def unique(self) -> Series: ... def hist( @@ -196,8 +196,12 @@ class DataFrameGroupBy(GroupBy): drop: bool = ..., method: str = ..., ) -> Series: ... - def cummax(self, axis: AxisType = ..., **kwargs) -> DataFrame: ... - def cummin(self, axis: AxisType = ..., **kwargs) -> DataFrame: ... + def cummax( + self, axis: AxisType = ..., numeric_only: bool = ..., **kwargs + ) -> DataFrame: ... + def cummin( + self, axis: AxisType = ..., numeric_only: bool = ..., **kwargs + ) -> DataFrame: ... def cumprod(self, axis: AxisType = ..., **kwargs) -> DataFrame: ... def cumsum(self, axis: AxisType = ..., **kwargs) -> DataFrame: ... def describe(self, **kwargs) -> DataFrame: ... @@ -255,28 +259,13 @@ class DataFrameGroupBy(GroupBy): backend: str | None = ..., **kwargs, ) -> AxesSubplot | Sequence[AxesSubplot]: ... - def idxmax(self, axis: AxisType = ..., skipna: bool = ...) -> Series: ... - def idxmin(self, axis: AxisType = ..., skipna: bool = ...) -> Series: ... - def last(self, **kwargs) -> DataFrame: ... - @overload - def mad( - self, - axis: AxisType = ..., - skipna: bool = ..., - numeric_only: bool | None = ..., - *, - level: Level, - **kwargs, - ) -> DataFrame: ... - @overload - def mad( - self, - axis: AxisType = ..., - skipna: bool = ..., - level: None = ..., - numeric_only: bool | None = ..., - **kwargs, + def idxmax( + self, axis: AxisType = ..., skipna: bool = ..., numeric_only: bool = ... + ) -> Series: ... + def idxmin( + self, axis: AxisType = ..., skipna: bool = ..., numeric_only: bool = ... ) -> Series: ... + def last(self, **kwargs) -> DataFrame: ... def max(self, **kwargs) -> DataFrame: ... def mean(self, **kwargs) -> DataFrame: ... def median(self, **kwargs) -> DataFrame: ... @@ -291,7 +280,9 @@ class DataFrameGroupBy(GroupBy): axis: AxisType = ..., ) -> DataFrame: ... def prod(self, numeric_only: bool = ..., min_count: int = ...) -> DataFrame: ... - def quantile(self, q: float = ..., interpolation: str = ...) -> DataFrame: ... + def quantile( + self, q: float = ..., interpolation: str = ..., numeric_only: bool = ... + ) -> DataFrame: ... def resample(self, rule, *args, **kwargs) -> Grouper: ... def sample( self, @@ -301,7 +292,7 @@ class DataFrameGroupBy(GroupBy): weights: ListLike | None = ..., random_state: int | None = ..., ) -> DataFrame: ... - def sem(self, ddof: int = ...) -> DataFrame: ... + def sem(self, ddof: int = ..., numeric_only: bool = ...) -> DataFrame: ... def shift( self, periods: int = ..., @@ -328,7 +319,7 @@ class DataFrameGroupBy(GroupBy): numeric_only: bool = ..., **kwargs, ) -> Series: ... - def std(self, ddof: int = ...) -> DataFrame: ... + def std(self, ddof: int = ..., numeric_only: bool = ...) -> DataFrame: ... def sum( self, numeric_only: bool = ..., @@ -339,7 +330,7 @@ class DataFrameGroupBy(GroupBy): def tail(self, n: int = ...) -> DataFrame: ... def take(self, indices: Sequence, axis: AxisType = ..., **kwargs) -> DataFrame: ... def tshift(self, periods: int, freq=..., axis: AxisType = ...) -> DataFrame: ... - def var(self, ddof: int = ...) -> DataFrame: ... + def var(self, ddof: int = ..., numeric_only: bool = ...) -> DataFrame: ... @overload def value_counts( self, diff --git a/pandas-stubs/core/groupby/groupby.pyi b/pandas-stubs/core/groupby/groupby.pyi index f1356b2fe..8c3b8171a 100644 --- a/pandas-stubs/core/groupby/groupby.pyi +++ b/pandas-stubs/core/groupby/groupby.pyi @@ -71,9 +71,9 @@ class GroupBy(BaseGroupBy[NDFrameT]): def count(self) -> DataFrame | Series: ... def mean(self, **kwargs) -> DataFrame | Series: ... def median(self, **kwargs) -> DataFrame | Series: ... - def std(self, ddof: int = ...) -> DataFrame | Series: ... - def var(self, ddof: int = ...) -> DataFrame | Series: ... - def sem(self, ddof: int = ...) -> DataFrame | Series: ... + def std(self, ddof: int = ..., numeric_only: bool = ...) -> DataFrame | Series: ... + def var(self, ddof: int = ..., numeric_only: bool = ...) -> DataFrame | Series: ... + def sem(self, ddof: int = ..., numeric_only: bool = ...) -> DataFrame | Series: ... def ohlc(self) -> DataFrame: ... def describe(self, **kwargs) -> DataFrame | Series: ... def resample(self, rule, *args, **kwargs): ... diff --git a/pandas-stubs/core/indexes/base.pyi b/pandas-stubs/core/indexes/base.pyi index 4c33b9d31..813cc4b9f 100644 --- a/pandas-stubs/core/indexes/base.pyi +++ b/pandas-stubs/core/indexes/base.pyi @@ -107,8 +107,6 @@ class Index(IndexOpsMixin, PandasObject): def get_level_values(self, level: int | _str) -> Index: ... def droplevel(self, level: Level | list[Level] = ...): ... @property - def is_monotonic(self) -> bool: ... - @property def is_monotonic_increasing(self) -> bool: ... @property def is_monotonic_decreasing(self) -> bool: ... @@ -162,6 +160,7 @@ class Index(IndexOpsMixin, PandasObject): def join( self, other, + *, how: _str = ..., level=..., return_indexers: bool = ..., diff --git a/pandas-stubs/core/indexes/multi.pyi b/pandas-stubs/core/indexes/multi.pyi index d11379043..c71c75c4d 100644 --- a/pandas-stubs/core/indexes/multi.pyi +++ b/pandas-stubs/core/indexes/multi.pyi @@ -92,8 +92,6 @@ class MultiIndex(Index): def to_flat_index(self): ... @property def is_all_dates(self) -> bool: ... - def is_lexsorted(self) -> bool: ... - def lexsort_depth(self): ... def remove_unused_levels(self): ... @property def nlevels(self) -> int: ... diff --git a/pandas-stubs/core/indexing.pyi b/pandas-stubs/core/indexing.pyi index 90374106b..aa0e163ea 100644 --- a/pandas-stubs/core/indexing.pyi +++ b/pandas-stubs/core/indexing.pyi @@ -24,9 +24,6 @@ class _IndexSlice: IndexSlice: _IndexSlice -# TODO: Remove from here after 1.5.x, moved to pandas.errors -class IndexingError(Exception): ... - class IndexingMixin: @property def iloc(self) -> _iLocIndexer: ... diff --git a/pandas-stubs/core/resample.pyi b/pandas-stubs/core/resample.pyi index 567c73aed..f01aca473 100644 --- a/pandas-stubs/core/resample.pyi +++ b/pandas-stubs/core/resample.pyi @@ -161,8 +161,12 @@ class Resampler(BaseGroupBy, Generic[NDFrameT]): **kwargs, ) -> NDFrameT: ... def asfreq(self, fill_value: Scalar | None = ...) -> NDFrameT: ... - def std(self, ddof: int = ..., *args, **kwargs) -> NDFrameT: ... - def var(self, ddof: int = ..., *args, **kwargs) -> NDFrameT: ... + def std( + self, ddof: int = ..., numeric_only: bool = ..., *args, **kwargs + ) -> NDFrameT: ... + def var( + self, ddof: int = ..., numeric_only: bool = ..., *args, **kwargs + ) -> NDFrameT: ... def size(self) -> Series: ... def count(self) -> NDFrameT: ... def quantile( @@ -171,25 +175,25 @@ class Resampler(BaseGroupBy, Generic[NDFrameT]): **kwargs, ) -> NDFrameT: ... def sum( - self, _method: Literal["sum"] = ..., min_count: int = ..., *args, **kwargs + self, numeric_only: bool = ..., min_count: int = ..., *args, **kwargs ) -> NDFrameT: ... def prod( - self, _method: Literal["prod"] = ..., min_count: int = ..., *args, **kwargs + self, numeric_only: bool = ..., min_count: int = ..., *args, **kwargs ) -> NDFrameT: ... def min( - self, _method: Literal["min"] = ..., min_count: int = ..., *args, **kwargs + self, numeric_only: bool = ..., min_count: int = ..., *args, **kwargs ) -> NDFrameT: ... def max( - self, _method: Literal["max"] = ..., min_count: int = ..., *args, **kwargs + self, numeric_only: bool = ..., min_count: int = ..., *args, **kwargs ) -> NDFrameT: ... def first( - self, _method: Literal["first"] = ..., min_count: int = ..., *args, **kwargs + self, numeric_only: bool = ..., min_count: int = ..., *args, **kwargs ) -> NDFrameT: ... def last( - self, _method: Literal["last"] = ..., min_count: int = ..., *args, **kwargs + self, numeric_only: bool = ..., min_count: int = ..., *args, **kwargs ) -> NDFrameT: ... - def mean(self, _method: Literal["mean"] = ..., *args, **kwargs) -> NDFrameT: ... - def sem(self, _method: Literal["sem"] = ..., *args, **kwargs) -> NDFrameT: ... - def median(self, _method: Literal["median"] = ..., *args, **kwargs) -> NDFrameT: ... - def ohlc(self, _method: Literal["ohlc"] = ..., *args, **kwargs) -> DataFrame: ... - def nunique(self, _method: Literal["first"] = ..., *args, **kwargs) -> NDFrameT: ... + def mean(self, numeric_only: bool = ..., *args, **kwargs) -> NDFrameT: ... + def sem(self, numeric_only: bool = ..., *args, **kwargs) -> NDFrameT: ... + def median(self, numeric_only: bool = ..., *args, **kwargs) -> NDFrameT: ... + def ohlc(self, *args, **kwargs) -> DataFrame: ... + def nunique(self, *args, **kwargs) -> NDFrameT: ... diff --git a/pandas-stubs/core/reshape/pivot.pyi b/pandas-stubs/core/reshape/pivot.pyi index bd32b8abe..ab327bc8a 100644 --- a/pandas-stubs/core/reshape/pivot.pyi +++ b/pandas-stubs/core/reshape/pivot.pyi @@ -27,6 +27,7 @@ def pivot_table( ) -> DataFrame: ... def pivot( data: DataFrame, + *, index: IndexLabel = ..., columns: IndexLabel = ..., values: IndexLabel = ..., diff --git a/pandas-stubs/core/series.pyi b/pandas-stubs/core/series.pyi index e451c8efc..425eff991 100644 --- a/pandas-stubs/core/series.pyi +++ b/pandas-stubs/core/series.pyi @@ -80,7 +80,6 @@ from pandas._typing import ( IgnoreRaise, IndexingInt, JsonSeriesOrient, - Label, Level, ListLike, MaskType, @@ -396,7 +395,6 @@ class Series(IndexOpsMixin, NDFrame, Generic[S1]): ) -> _str: ... def to_xarray(self) -> xr.DataArray: ... def items(self) -> Iterable[tuple[Hashable, S1]]: ... - def iteritems(self) -> Iterable[tuple[Label, S1]]: ... def keys(self) -> list: ... @overload def to_dict(self) -> dict[Hashable, S1]: ... @@ -1087,7 +1085,7 @@ class Series(IndexOpsMixin, NDFrame, Generic[S1]): inplace: _bool = ..., axis: SeriesAxisType | None = ..., level: Level | None = ..., - errors: _str = ..., + *, # Not actually positional-only, but needed due to depr in 1.5.0 try_cast: _bool = ..., ) -> Series[S1]: ... def mask( @@ -1097,7 +1095,7 @@ class Series(IndexOpsMixin, NDFrame, Generic[S1]): inplace: _bool = ..., axis: SeriesAxisType | None = ..., level: Level | None = ..., - errors: IgnoreRaise = ..., + *, # Not actually positional-only, but needed due to depr in 1.5.0 try_cast: _bool = ..., ) -> Series[S1]: ... def slice_shift( @@ -1266,6 +1264,7 @@ class Series(IndexOpsMixin, NDFrame, Generic[S1]): ) -> _bool: ... def any( self, + *, axis: SeriesAxisType = ..., bool_only: _bool | None = ..., skipna: _bool = ..., @@ -1348,7 +1347,7 @@ class Series(IndexOpsMixin, NDFrame, Generic[S1]): axis: SeriesAxisType | None = ..., skipna: _bool = ..., level: None = ..., - numeric_only: _bool | None = ..., + numeric_only: _bool = ..., **kwargs, ) -> Scalar: ... def kurtosis( @@ -1356,7 +1355,7 @@ class Series(IndexOpsMixin, NDFrame, Generic[S1]): axis: SeriesAxisType | None = ..., skipna: _bool = ..., level: None = ..., - numeric_only: _bool | None = ..., + numeric_only: _bool = ..., **kwargs, ) -> Scalar: ... def le( @@ -1373,29 +1372,12 @@ class Series(IndexOpsMixin, NDFrame, Generic[S1]): fill_value: float | None = ..., axis: SeriesAxisType = ..., ) -> Series[_bool]: ... - @overload - def mad( - self, - axis: SeriesAxisType | None = ..., - skipna: _bool = ..., - *, - level: Level, - **kwargs, - ) -> Series[S1]: ... - @overload - def mad( - self, - axis: SeriesAxisType | None = ..., - skipna: _bool = ..., - level: None = ..., - **kwargs, - ) -> Scalar: ... def max( self, axis: SeriesAxisType | None = ..., skipna: _bool = ..., level: None = ..., - numeric_only: _bool | None = ..., + numeric_only: _bool = ..., **kwargs, ) -> S1: ... def mean( @@ -1403,7 +1385,7 @@ class Series(IndexOpsMixin, NDFrame, Generic[S1]): axis: SeriesAxisType | None = ..., skipna: _bool = ..., level: None = ..., - numeric_only: _bool | None = ..., + numeric_only: _bool = ..., **kwargs, ) -> float: ... def median( @@ -1411,7 +1393,7 @@ class Series(IndexOpsMixin, NDFrame, Generic[S1]): axis: SeriesAxisType | None = ..., skipna: _bool = ..., level: None = ..., - numeric_only: _bool | None = ..., + numeric_only: _bool = ..., **kwargs, ) -> float: ... def min( @@ -1419,7 +1401,7 @@ class Series(IndexOpsMixin, NDFrame, Generic[S1]): axis: SeriesAxisType | None = ..., skipna: _bool = ..., level: None = ..., - numeric_only: _bool | None = ..., + numeric_only: _bool = ..., **kwargs, ) -> S1: ... def mod( @@ -1463,7 +1445,7 @@ class Series(IndexOpsMixin, NDFrame, Generic[S1]): axis: SeriesAxisType | None = ..., skipna: _bool | None = ..., level: None = ..., - numeric_only: _bool | None = ..., + numeric_only: _bool = ..., min_count: int = ..., **kwargs, ) -> Scalar: ... @@ -1472,7 +1454,7 @@ class Series(IndexOpsMixin, NDFrame, Generic[S1]): axis: SeriesAxisType | None = ..., skipna: _bool | None = ..., level: None = ..., - numeric_only: _bool | None = ..., + numeric_only: _bool = ..., min_count: int = ..., **kwargs, ) -> Scalar: ... @@ -1562,7 +1544,7 @@ class Series(IndexOpsMixin, NDFrame, Generic[S1]): skipna: _bool | None = ..., level: None = ..., ddof: int = ..., - numeric_only: _bool | None = ..., + numeric_only: _bool = ..., **kwargs, ) -> Scalar: ... def skew( @@ -1570,7 +1552,7 @@ class Series(IndexOpsMixin, NDFrame, Generic[S1]): axis: SeriesAxisType | None = ..., skipna: _bool | None = ..., level: None = ..., - numeric_only: _bool | None = ..., + numeric_only: _bool = ..., **kwargs, ) -> Scalar: ... def std( @@ -1579,7 +1561,7 @@ class Series(IndexOpsMixin, NDFrame, Generic[S1]): skipna: _bool | None = ..., level: None = ..., ddof: int = ..., - numeric_only: _bool | None = ..., + numeric_only: _bool = ..., **kwargs, ) -> float: ... def sub( @@ -1601,7 +1583,7 @@ class Series(IndexOpsMixin, NDFrame, Generic[S1]): axis: SeriesAxisType | None = ..., skipna: _bool | None = ..., level: None = ..., - numeric_only: _bool | None = ..., + numeric_only: _bool = ..., min_count: int = ..., **kwargs, ) -> S1: ... @@ -1627,7 +1609,7 @@ class Series(IndexOpsMixin, NDFrame, Generic[S1]): skipna: _bool | None = ..., level: None = ..., ddof: int = ..., - numeric_only: _bool | None = ..., + numeric_only: _bool = ..., **kwargs, ) -> Scalar: ... @overload @@ -1651,18 +1633,8 @@ class Series(IndexOpsMixin, NDFrame, Generic[S1]): copy: _bool = ..., inplace: Literal[False] = ..., ) -> Series: ... - @overload - def set_axis( - self, labels, axis: Axis = ..., inplace: Literal[False] = ... - ) -> Series[S1]: ... - @overload - def set_axis(self, labels, axis: Axis, inplace: Literal[True]) -> None: ... - @overload - def set_axis(self, labels, *, inplace: Literal[True]) -> None: ... - @overload - def set_axis( - self, labels, axis: Axis = ..., inplace: bool = ... - ) -> Series[S1] | None: ... + # Not actually positional, but used to handle removal of deprecated + def set_axis(self, labels, axis: Axis = ..., copy: _bool = ...) -> Series[S1]: ... def __iter__(self) -> Iterator[S1]: ... class TimestampSeries(Series[Timestamp]): diff --git a/pandas-stubs/core/strings.pyi b/pandas-stubs/core/strings.pyi index e0f1eca42..b9ffceea0 100644 --- a/pandas-stubs/core/strings.pyi +++ b/pandas-stubs/core/strings.pyi @@ -57,19 +57,19 @@ class StringMethods(NoNewAttributesMixin, Generic[T, _TS]): ) -> T: ... @overload def split( - self, pat: str = ..., n: int = ..., *, expand: Literal[True], regex: bool = ... + self, pat: str = ..., *, n: int = ..., expand: Literal[True], regex: bool = ... ) -> _TS: ... @overload def split( - self, pat: str = ..., n: int = ..., *, expand: bool = ..., regex: bool = ... + self, pat: str = ..., *, n: int = ..., expand: bool = ..., regex: bool = ... ) -> T: ... @overload def rsplit( - self, pat: str = ..., n: int = ..., *, expand: Literal[True], regex: bool = ... - ) -> T: ... + self, pat: str = ..., *, n: int = ..., expand: Literal[True], regex: bool = ... + ) -> _TS: ... @overload def rsplit( - self, pat: str = ..., n: int = ..., *, expand: bool = ..., regex: bool = ... + self, pat: str = ..., *, n: int = ..., expand: bool = ..., regex: bool = ... ) -> T: ... @overload def partition(self, sep: str = ...) -> pd.DataFrame: ... diff --git a/pandas-stubs/core/window/ewm.pyi b/pandas-stubs/core/window/ewm.pyi index ce70571d0..425f2658f 100644 --- a/pandas-stubs/core/window/ewm.pyi +++ b/pandas-stubs/core/window/ewm.pyi @@ -61,26 +61,30 @@ class ExponentialMovingWindow(BaseWindow[NDFrameT], Generic[NDFrameT]): ) -> DataFrame: ... def mean( self, + numeric_only: bool = ..., *, engine: WindowingEngine = ..., engine_kwargs: WindowingEngineKwargs = ..., ) -> NDFrameT: ... def sum( self, + numeric_only: bool = ..., *, engine: WindowingEngine = ..., engine_kwargs: WindowingEngineKwargs = ..., ) -> NDFrameT: ... - def std(self, bias: bool = ...) -> NDFrameT: ... - def var(self, bias: bool = ...) -> NDFrameT: ... + def std(self, bias: bool = ..., numeric_only: bool = ...) -> NDFrameT: ... + def var(self, bias: bool = ..., numeric_only: bool = ...) -> NDFrameT: ... def cov( self, other: DataFrame | Series | None = ..., pairwise: bool | None = ..., bias: bool = ..., + numeric_only: bool = ..., ) -> NDFrameT: ... def corr( self, other: DataFrame | Series | None = ..., pairwise: bool | None = ..., + numeric_only: bool = ..., ) -> NDFrameT: ... diff --git a/pandas-stubs/core/window/expanding.pyi b/pandas-stubs/core/window/expanding.pyi index 9139c74bd..1c3b164ff 100644 --- a/pandas-stubs/core/window/expanding.pyi +++ b/pandas-stubs/core/window/expanding.pyi @@ -56,36 +56,42 @@ class Expanding(RollingAndExpandingMixin[NDFrameT]): ) -> NDFrameT: ... def sum( self, + numeric_only: bool = ..., *, engine: WindowingEngine = ..., engine_kwargs: WindowingEngineKwargs = ..., ) -> NDFrameT: ... def max( self, + numeric_only: bool = ..., *, engine: WindowingEngine = ..., engine_kwargs: WindowingEngineKwargs = ..., ) -> NDFrameT: ... def min( self, + numeric_only: bool = ..., *, engine: WindowingEngine = ..., engine_kwargs: WindowingEngineKwargs = ..., ) -> NDFrameT: ... def mean( self, + numeric_only: bool = ..., *, engine: WindowingEngine = ..., engine_kwargs: WindowingEngineKwargs = ..., ) -> NDFrameT: ... def median( self, + numeric_only: bool = ..., engine: WindowingEngine = ..., engine_kwargs: WindowingEngineKwargs = ..., ) -> NDFrameT: ... def std( self, ddof: int = ..., + numeric_only: bool = ..., *, engine: WindowingEngine = ..., engine_kwargs: WindowingEngineKwargs = ..., @@ -93,35 +99,46 @@ class Expanding(RollingAndExpandingMixin[NDFrameT]): def var( self, ddof: int = ..., + numeric_only: bool = ..., *, engine: WindowingEngine = ..., engine_kwargs: WindowingEngineKwargs = ..., ) -> NDFrameT: ... - def sem(self, ddof: int = ...) -> NDFrameT: ... - def skew(self) -> NDFrameT: ... - def kurt(self) -> NDFrameT: ... + def sem(self, ddof: int = ..., numeric_only: bool = ...) -> NDFrameT: ... + def skew( + self, + numeric_only: bool = ..., + ) -> NDFrameT: ... + def kurt( + self, + numeric_only: bool = ..., + ) -> NDFrameT: ... def quantile( self, quantile: float, interpolation: QuantileInterpolation = ..., + numeric_only: bool = ..., ) -> NDFrameT: ... def rank( self, method: WindowingRankType = ..., ascending: bool = ..., pct: bool = ..., + numeric_only: bool = ..., ) -> NDFrameT: ... def cov( self, other: DataFrame | Series | None = ..., pairwise: bool | None = ..., ddof: int = ..., + numeric_only: bool = ..., ) -> NDFrameT: ... def corr( self, other: DataFrame | Series | None = ..., pairwise: bool | None = ..., ddof: int = ..., + numeric_only: bool = ..., ) -> NDFrameT: ... class ExpandingGroupby(BaseWindowGroupby, Expanding): ... diff --git a/pandas-stubs/core/window/rolling.pyi b/pandas-stubs/core/window/rolling.pyi index c199bffb8..de3eb8357 100644 --- a/pandas-stubs/core/window/rolling.pyi +++ b/pandas-stubs/core/window/rolling.pyi @@ -67,10 +67,14 @@ class Window(BaseWindow[NDFrameT]): *args: Any, **kwargs: Any, ) -> DataFrame: ... - def sum(self, **kwargs: Any) -> NDFrameT: ... - def mean(self, **kwargs: Any) -> NDFrameT: ... - def var(self, ddof: int = ..., **kwargs: Any) -> NDFrameT: ... - def std(self, ddof: int = ..., **kwargs: Any) -> NDFrameT: ... + def sum(self, numeric_only: bool = ..., **kwargs: Any) -> NDFrameT: ... + def mean(self, numeric_only: bool = ..., **kwargs: Any) -> NDFrameT: ... + def var( + self, ddof: int = ..., numeric_only: bool = ..., *args: Any, **kwargs: Any + ) -> NDFrameT: ... + def std( + self, ddof: int = ..., numeric_only: bool = ..., *args: Any, **kwargs: Any + ) -> NDFrameT: ... class RollingAndExpandingMixin(BaseWindow[NDFrameT], Generic[NDFrameT]): def count(self) -> NDFrameT: ... @@ -85,36 +89,42 @@ class RollingAndExpandingMixin(BaseWindow[NDFrameT], Generic[NDFrameT]): ) -> NDFrameT: ... def sum( self, + numeric_only: bool = ..., *, engine: WindowingEngine = ..., engine_kwargs: WindowingEngineKwargs = ..., ) -> NDFrameT: ... def max( self, + numeric_only: bool = ..., *, engine: WindowingEngine = ..., engine_kwargs: WindowingEngineKwargs = ..., ) -> NDFrameT: ... def min( self, + numeric_only: bool = ..., *, engine: WindowingEngine = ..., engine_kwargs: WindowingEngineKwargs = ..., ) -> NDFrameT: ... def mean( self, + numeric_only: bool = ..., *, engine: WindowingEngine = ..., engine_kwargs: WindowingEngineKwargs = ..., ) -> NDFrameT: ... def median( self, + numeric_only: bool = ..., engine: WindowingEngine = ..., engine_kwargs: WindowingEngineKwargs = ..., ) -> NDFrameT: ... def std( self, ddof: int = ..., + numeric_only: bool = ..., *, engine: WindowingEngine = ..., engine_kwargs: WindowingEngineKwargs = ..., @@ -122,35 +132,44 @@ class RollingAndExpandingMixin(BaseWindow[NDFrameT], Generic[NDFrameT]): def var( self, ddof: int = ..., + numeric_only: bool = ..., *, engine: WindowingEngine = ..., engine_kwargs: WindowingEngineKwargs = ..., ) -> NDFrameT: ... - def skew(self) -> NDFrameT: ... - def sem(self, ddof: int = ...) -> NDFrameT: ... - def kurt(self) -> NDFrameT: ... + def skew(self, numeric_only: bool = ...) -> NDFrameT: ... + def sem( + self, + ddof: int = ..., + numeric_only: bool = ..., + ) -> NDFrameT: ... + def kurt(self, numeric_only: bool = ...) -> NDFrameT: ... def quantile( self, quantile: float, interpolation: QuantileInterpolation = ..., + numeric_only: bool = ..., ) -> NDFrameT: ... def rank( self, method: WindowingRankType = ..., ascending: bool = ..., pct: bool = ..., + numeric_only: bool = ..., ) -> NDFrameT: ... def cov( self, other: DataFrame | Series | None = ..., pairwise: bool | None = ..., ddof: int = ..., + numeric_only: bool = ..., ) -> NDFrameT: ... def corr( self, other: DataFrame | Series | None = ..., pairwise: bool | None = ..., ddof: int = ..., + numeric_only: bool = ..., ) -> NDFrameT: ... class Rolling(RollingAndExpandingMixin[NDFrameT]): diff --git a/pandas-stubs/errors/__init__.pyi b/pandas-stubs/errors/__init__.pyi index 50bc8d61d..6f9f7456a 100644 --- a/pandas-stubs/errors/__init__.pyi +++ b/pandas-stubs/errors/__init__.pyi @@ -1,3 +1,5 @@ +from pandas.core.computation.ops import UndefinedVariableError as UndefinedVariableError + from pandas._config.config import OptionError as OptionError from pandas._libs.tslibs import ( @@ -5,11 +7,6 @@ from pandas._libs.tslibs import ( OutOfBoundsTimedelta as OutOfBoundsTimedelta, ) -from pandas.io.clipboard import PyperclipWindowsException as PyperclipWindowsException - -# TODO: Uncomment import below after switch to 1.5.x. -# from pandas.core.computation.ops import UndefinedVariableError as UndefinedVariableError - class IntCastingNaNError(ValueError): ... class NullFrequencyError(ValueError): ... class PerformanceWarning(Warning): ... @@ -28,30 +25,24 @@ class AbstractMethodError(NotImplementedError): class NumbaUtilError(Exception): ... class DuplicateLabelError(ValueError): ... class InvalidIndexError(Exception): ... +class DataError(Exception): ... +class SpecificationError(Exception): ... +class SettingWithCopyError(ValueError): ... +class SettingWithCopyWarning(Warning): ... +class NumExprClobberingError(NameError): ... +class IndexingError(Exception): ... +class PyperclipException(RuntimeError): ... + +class PyperclipWindowsException(PyperclipException): + def __init__(self, message) -> None: ... -# TODO: Uncomment and delete from pandas.core.base after switch to 1.5.x -# class DataError(Exception): ... -# class SpecificationError(Exception): ... -# TODO: Uncomment and delete from pandas.core.common after switch to 1.5.x -# class SettingWithCopyError(ValueError): ... -# class SettingWithCopyWarning(Warning): ... -# TODO: Uncomment and delete from pandas.core.computation.engines after switch to 1.5.x -# class NumExprClobberingError(NameError): ... -# TODO: Uncomment and delete from core.indexing after switch to 1.5.x -# class IndexingError(Exception): ... -# TODO: Uncomment and delete from io.clipboards.__init__ after switch to 1.5.x -# class PyperclipException(RuntimeError): ... -# TODO: Uncomment and delete from io.formats.css after switch to 1.5.x -# class CSSWarning(UserWarning): ... -# TODO: Uncomment and delete next 4 from io.pytables after switch to 1.5.x -# class PossibleDataLossError(Exception): ... -# class ClosedFileError(Exception): ... -# class IncompatibilityWarning(Warning): ... -# class AttributeConflictWarning(Warning): ... -# TODO: Uncomment and delete from io.sql after switch to 1.5.x -# class DatabaseError(OSError): ... -# TODO: Uncomment and delete from io.stata after switch to 1.5.x -# class PossiblePrecisionLoss(Warning): ... -# class ValueLabelTypeMismatch(Warning): ... -# class InvalidColumnName(Warning): ... -# class CategoricalConversionWarning(Warning): ... +class CSSWarning(UserWarning): ... +class PossibleDataLossError(Exception): ... +class ClosedFileError(Exception): ... +class IncompatibilityWarning(Warning): ... +class AttributeConflictWarning(Warning): ... +class DatabaseError(OSError): ... +class PossiblePrecisionLoss(Warning): ... +class ValueLabelTypeMismatch(Warning): ... +class InvalidColumnName(Warning): ... +class CategoricalConversionWarning(Warning): ... diff --git a/pandas-stubs/io/clipboard/__init__.pyi b/pandas-stubs/io/clipboard/__init__.pyi index 459679130..e69de29bb 100644 --- a/pandas-stubs/io/clipboard/__init__.pyi +++ b/pandas-stubs/io/clipboard/__init__.pyi @@ -1,5 +0,0 @@ -# TODO: Remove PyperclipException after switch to 1.5.x, moved to pandas.errors -class PyperclipException(RuntimeError): ... - -class PyperclipWindowsException(PyperclipException): - def __init__(self, message) -> None: ... diff --git a/pandas-stubs/io/clipboards.pyi b/pandas-stubs/io/clipboards.pyi index fc83d80ba..b1cb8f95d 100644 --- a/pandas-stubs/io/clipboards.pyi +++ b/pandas-stubs/io/clipboards.pyi @@ -38,9 +38,6 @@ def read_clipboard( | npt.NDArray | Callable[[str], bool] | None = ..., - # squeeze: bool | None = ..., # deprecated: 1.4.0 - # prefix: str | None = ..., # deprecated: 1.4.0 - mangle_dupe_cols: bool = ..., # deprecated: 1.5.0 dtype: DtypeArg | None = ..., engine: CSVEngine | None = ..., converters: dict[int | str, Callable[[str], Any]] = ..., @@ -104,9 +101,6 @@ def read_clipboard( | npt.NDArray | Callable[[str], bool] | None = ..., - # squeeze: bool | None = ..., # deprecated: 1.4.0 - # prefix: str | None = ..., # deprecated: 1.4.0 - mangle_dupe_cols: bool = ..., # deprecated: 1.5.0 dtype: DtypeArg | None = ..., engine: CSVEngine | None = ..., converters: dict[int | str, Callable[[str], Any]] = ..., @@ -170,9 +164,6 @@ def read_clipboard( | npt.NDArray | Callable[[str], bool] | None = ..., - # squeeze: bool | None = ..., # deprecated: 1.4.0 - # prefix: str | None = ..., # deprecated: 1.4.0 - mangle_dupe_cols: bool = ..., # deprecated: 1.5.0 dtype: DtypeArg | None = ..., engine: CSVEngine | None = ..., converters: dict[int | str, Callable[[str], Any]] = ..., diff --git a/pandas-stubs/io/excel/_base.pyi b/pandas-stubs/io/excel/_base.pyi index 9048a95cb..d0426c8c5 100644 --- a/pandas-stubs/io/excel/_base.pyi +++ b/pandas-stubs/io/excel/_base.pyi @@ -2,7 +2,6 @@ from types import TracebackType from typing import ( Any, Callable, - Generator, Hashable, Iterable, Literal, @@ -24,8 +23,6 @@ from pandas._typing import ( WriteExcelBuffer, ) -from pandas.io.common import IOHandles - @overload def read_excel( io: FilePath @@ -123,27 +120,12 @@ class ExcelWriter: def sheets(self) -> dict[str, Any]: ... @property def book(self) -> Workbook | OpenDocument | pyxlsb.workbook.Workbook: ... - def write_cells( - self, - cells: Generator[object, None, None], - sheet_name: str | None = ..., - startrow: int = ..., - startcol: int = ..., - freeze_panes: tuple[int, int] | None = ..., - ) -> None: ... - def save(self) -> None: ... @property def date_format(self) -> str: ... @property def datetime_format(self) -> str: ... @property def if_sheet_exists(self) -> Literal["error", "new", "replace", "overlay"]: ... - @property - def cur_sheet(self) -> Any: ... - @property - def handles(self) -> IOHandles[bytes]: ... - @property - def path(self) -> str | None: ... def __fspath__(self) -> str: ... def __enter__(self) -> ExcelWriter: ... def __exit__( diff --git a/pandas-stubs/io/formats/css.pyi b/pandas-stubs/io/formats/css.pyi index 00cf1ff9b..e69de29bb 100644 --- a/pandas-stubs/io/formats/css.pyi +++ b/pandas-stubs/io/formats/css.pyi @@ -1,2 +0,0 @@ -# TODO: Remove after 1.5.x, moved to pandas.errors -class CSSWarning(UserWarning): ... diff --git a/pandas-stubs/io/formats/style.pyi b/pandas-stubs/io/formats/style.pyi index f2bad89ce..64e5a1e9e 100644 --- a/pandas-stubs/io/formats/style.pyi +++ b/pandas-stubs/io/formats/style.pyi @@ -53,6 +53,7 @@ class Styler(StylerRenderer[Styler]): escape: str | None = ..., formatter: ExtFormatter | None = ..., ) -> None: ... + def concat(self, other: Styler) -> Styler: ... def set_tooltips( self, ttips: DataFrame, @@ -160,6 +161,30 @@ class Styler(StylerRenderer[Styler]): exclude_styles: bool = ..., **kwargs: Any, ) -> str: ... + @overload + def to_string( + self, + buf: FilePath | WriteBuffer[str], + *, + encoding: str | None = ..., + sparse_index: bool | None = ..., + sparse_columns: bool | None = ..., + max_rows: int | None = ..., + max_columns: int | None = ..., + delimiter: str = ..., + ) -> None: ... + @overload + def to_string( + self, + buf: None = ..., + *, + encoding: str | None = ..., + sparse_index: bool | None = ..., + sparse_columns: bool | None = ..., + max_rows: int | None = ..., + max_columns: int | None = ..., + delimiter: str = ..., + ) -> str: ... def set_td_classes(self, classes: DataFrame) -> Styler: ... def __copy__(self) -> Styler: ... def __deepcopy__(self, memo) -> Styler: ... @@ -278,7 +303,7 @@ class Styler(StylerRenderer[Styler]): ) -> Styler: ... def highlight_null( self, - null_color: str = ..., + color: str | None = ..., subset: Subset | None = ..., props: str | None = ..., ) -> Styler: ... diff --git a/pandas-stubs/io/formats/style_render.pyi b/pandas-stubs/io/formats/style_render.pyi index db19a4e05..fa139a6af 100644 --- a/pandas-stubs/io/formats/style_render.pyi +++ b/pandas-stubs/io/formats/style_render.pyi @@ -4,6 +4,7 @@ from typing import ( Generic, Literal, Optional, + Sequence, TypedDict, TypeVar, Union, @@ -74,3 +75,9 @@ class StylerRenderer(Generic[_StylerT]): escape: str | None = ..., hyperlinks: Literal["html", "latex"] | None = ..., ) -> _StylerT: ... + def relabel_index( + self, + labels: Sequence[str] | Index, + axis: AxisType = ..., + level: Level | list[Level] | None = ..., + ) -> _StylerT: ... diff --git a/pandas-stubs/io/parsers/readers.pyi b/pandas-stubs/io/parsers/readers.pyi index 6c1fb327f..da3a69b7c 100644 --- a/pandas-stubs/io/parsers/readers.pyi +++ b/pandas-stubs/io/parsers/readers.pyi @@ -44,7 +44,6 @@ def read_csv( | npt.NDArray | Callable[[str], bool] | None = ..., - mangle_dupe_cols: bool = ..., dtype: DtypeArg | None = ..., engine: CSVEngine | None = ..., converters: dict[int | str, Callable[[str], Any]] = ..., @@ -108,7 +107,6 @@ def read_csv( | npt.NDArray | Callable[[str], bool] | None = ..., - mangle_dupe_cols: bool = ..., dtype: DtypeArg | None = ..., engine: CSVEngine | None = ..., converters: dict[int | str, Callable[[str], Any]] = ..., @@ -172,7 +170,6 @@ def read_csv( | npt.NDArray | Callable[[str], bool] | None = ..., - mangle_dupe_cols: bool = ..., dtype: DtypeArg | None = ..., engine: CSVEngine | None = ..., converters: dict[int | str, Callable[[str], Any]] = ..., diff --git a/pandas-stubs/io/pytables.pyi b/pandas-stubs/io/pytables.pyi index dfea4e0cd..9400a7569 100644 --- a/pandas-stubs/io/pytables.pyi +++ b/pandas-stubs/io/pytables.pyi @@ -23,13 +23,6 @@ from pandas._typing import ( Term = PyTablesExpr -# TODO: Remove these after switch to 1.5.x, moved to pandas.errors -class PossibleDataLossError(Exception): ... -class ClosedFileError(Exception): ... -class IncompatibilityWarning(Warning): ... -class AttributeConflictWarning(Warning): ... -class DuplicateWarning(Warning): ... - @overload def read_hdf( path_or_buf: FilePath | HDFStore, diff --git a/pandas-stubs/io/sql.pyi b/pandas-stubs/io/sql.pyi index 0d46dfb03..2f87bc4c7 100644 --- a/pandas-stubs/io/sql.pyi +++ b/pandas-stubs/io/sql.pyi @@ -19,9 +19,6 @@ from pandas._typing import ( npt, ) -# TODO: Remove after switch to 1.5.x, moved to pandas.errors -class DatabaseError(IOError): ... - _SQLConnection = Union[ str, sqlalchemy.engine.Connectable, diff --git a/pandas-stubs/io/stata.pyi b/pandas-stubs/io/stata.pyi index 75bc645b3..fb3c7bd48 100644 --- a/pandas-stubs/io/stata.pyi +++ b/pandas-stubs/io/stata.pyi @@ -26,6 +26,7 @@ from pandas._typing import ( @overload def read_stata( path: FilePath | ReadBuffer[bytes], + *, convert_dates: bool = ..., convert_categoricals: bool = ..., index_col: str | None = ..., @@ -34,7 +35,6 @@ def read_stata( columns: list[HashableT] | None = ..., order_categoricals: bool = ..., chunksize: int | None = ..., - *, iterator: Literal[True], compression: CompressionOptions = ..., storage_options: StorageOptions = ..., @@ -42,6 +42,7 @@ def read_stata( @overload def read_stata( path: FilePath | ReadBuffer[bytes], + *, convert_dates: bool, convert_categoricals: bool, index_col: str | None, @@ -49,14 +50,15 @@ def read_stata( preserve_dtypes: bool, columns: list[HashableT] | None, order_categoricals: bool, - chunksize: int | None, - iterator: Literal[True], + chunksize: int, + iterator: bool = ..., compression: CompressionOptions = ..., storage_options: StorageOptions = ..., ) -> StataReader: ... @overload def read_stata( path: FilePath | ReadBuffer[bytes], + *, convert_dates: bool = ..., convert_categoricals: bool = ..., index_col: str | None = ..., @@ -64,18 +66,12 @@ def read_stata( preserve_dtypes: bool = ..., columns: list[HashableT] | None = ..., order_categoricals: bool = ..., - chunksize: int | None = ..., + chunksize: None = ..., iterator: Literal[False] = ..., compression: CompressionOptions = ..., storage_options: StorageOptions = ..., ) -> DataFrame: ... -# TODO: Remove after switch to 1.5.x, moved to pandas.errors -class PossiblePrecisionLoss(Warning): ... -class ValueLabelTypeMismatch(Warning): ... -class InvalidColumnName(Warning): ... -class CategoricalConversionWarning(Warning): ... - class StataParser: def __init__(self) -> None: ... diff --git a/pandas-stubs/plotting/_core.pyi b/pandas-stubs/plotting/_core.pyi index 30b0c2033..b310ce8b8 100644 --- a/pandas-stubs/plotting/_core.pyi +++ b/pandas-stubs/plotting/_core.pyi @@ -130,7 +130,6 @@ class PlotAccessor(PandasObject): yerr: DataFrame | Series | ArrayLike | dict | str = ..., xerr: DataFrame | Series | ArrayLike | dict | str = ..., stacked: bool = ..., - sort_columns: bool = ..., secondary_y: bool | list[HashableT] | tuple[HashableT, ...] = ..., mark_right: bool = ..., include_bool: bool = ..., @@ -185,7 +184,6 @@ class PlotAccessor(PandasObject): yerr: DataFrame | Series | ArrayLike | dict | str = ..., xerr: DataFrame | Series | ArrayLike | dict | str = ..., stacked: bool = ..., - sort_columns: bool = ..., secondary_y: bool | list[HashableT] | tuple[HashableT, ...] = ..., mark_right: bool = ..., include_bool: bool = ..., @@ -229,7 +227,6 @@ class PlotAccessor(PandasObject): yerr: DataFrame | Series | ArrayLike | dict | str = ..., xerr: DataFrame | Series | ArrayLike | dict | str = ..., stacked: bool = ..., - sort_columns: bool = ..., secondary_y: bool | list[HashableT] | tuple[HashableT, ...] = ..., mark_right: bool = ..., include_bool: bool = ..., diff --git a/pandas-stubs/tseries/frequencies.pyi b/pandas-stubs/tseries/frequencies.pyi index 89daf614b..70da435f2 100644 --- a/pandas-stubs/tseries/frequencies.pyi +++ b/pandas-stubs/tseries/frequencies.pyi @@ -3,4 +3,4 @@ from pandas.tseries.offsets import DateOffset as DateOffset def get_period_alias(offset_str: str) -> str | None: ... def to_offset(freq) -> DateOffset | None: ... def get_offset(name: str) -> DateOffset: ... -def infer_freq(index, warn: bool = ...) -> str | None: ... +def infer_freq(index) -> str | None: ... diff --git a/pyproject.toml b/pyproject.toml index 0430664be..2d2df1b77 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -41,7 +41,7 @@ pytest = ">=7.1.2" pyright = ">=1.1.266" poethepoet = "0.16.0" loguru = ">=0.6.0" -pandas = "1.4.4" +pandas = "1.5.0" typing-extensions = ">=4.2.0" matplotlib = "~=3.5.0" pre-commit = ">=2.19.0" diff --git a/tests/__init__.py b/tests/__init__.py index b6f0442ef..da22394ff 100644 --- a/tests/__init__.py +++ b/tests/__init__.py @@ -1,17 +1,16 @@ from __future__ import annotations +import os +import platform from typing import ( TYPE_CHECKING, Final, ) -from packaging.version import parse -import pandas as pd - from pandas._typing import T TYPE_CHECKING_INVALID_USAGE: Final = TYPE_CHECKING -PD_LT_15 = parse(pd.__version__) < parse("1.5.0") +WINDOWS = os.name == "nt" or "cygwin" in platform.system().lower() def check(actual: T, klass: type, dtype: type | None = None, attr: str = "left") -> T: diff --git a/tests/test_errors.py b/tests/test_errors.py index 65fb26811..f507302a6 100644 --- a/tests/test_errors.py +++ b/tests/test_errors.py @@ -1,69 +1,9 @@ -import os -import platform -from typing import TYPE_CHECKING import warnings from pandas import errors import pytest -from tests import PD_LT_15 - -if TYPE_CHECKING or PD_LT_15: - # TODO: Remove all imports below after switch to 1.5.x, these moved to pandas.errors - from pandas.core.base import ( - DataError, - SpecificationError, - ) - from pandas.core.common import ( - SettingWithCopyError, - SettingWithCopyWarning, - ) - from pandas.core.computation.engines import NumExprClobberingError - from pandas.core.computation.ops import UndefinedVariableError - from pandas.core.indexing import IndexingError - - from pandas.io.clipboard import ( - PyperclipException, - PyperclipWindowsException, - ) - from pandas.io.formats.css import CSSWarning - from pandas.io.pytables import ( - AttributeConflictWarning, - ClosedFileError, - IncompatibilityWarning, - PossibleDataLossError, - ) - from pandas.io.sql import DatabaseError - from pandas.io.stata import ( - CategoricalConversionWarning, - InvalidColumnName, - PossiblePrecisionLoss, - ValueLabelTypeMismatch, - ) -else: - from pandas.errors import ( - AttributeConflictWarning, - CategoricalConversionWarning, - ClosedFileError, - CSSWarning, - DatabaseError, - DataError, - IncompatibilityWarning, - IndexingError, - InvalidColumnName, - NumExprClobberingError, - PossibleDataLossError, - PossiblePrecisionLoss, - PyperclipException, - PyperclipWindowsException, - SettingWithCopyError, - SettingWithCopyWarning, - SpecificationError, - UndefinedVariableError, - ValueLabelTypeMismatch, - ) - -WINDOWS = os.name == "nt" or "cygwin" in platform.system().lower() +from tests import WINDOWS def test_abstract_method_error() -> None: @@ -160,96 +100,96 @@ def test_unsupported_function_call() -> None: def test_data_error() -> None: - with pytest.raises(DataError): - raise DataError() + with pytest.raises(errors.DataError): + raise errors.DataError() def test_specification_error() -> None: - with pytest.raises(SpecificationError): - raise SpecificationError() + with pytest.raises(errors.SpecificationError): + raise errors.SpecificationError() def test_setting_with_copy_error() -> None: - with pytest.raises(SettingWithCopyError): - raise SettingWithCopyError() + with pytest.raises(errors.SettingWithCopyError): + raise errors.SettingWithCopyError() def test_setting_with_copy_warning() -> None: - with pytest.warns(SettingWithCopyWarning): - warnings.warn("", SettingWithCopyWarning) + with pytest.warns(errors.SettingWithCopyWarning): + warnings.warn("", errors.SettingWithCopyWarning) def test_numexpr_clobbering_error() -> None: - with pytest.raises(NumExprClobberingError): - raise NumExprClobberingError() + with pytest.raises(errors.NumExprClobberingError): + raise errors.NumExprClobberingError() def test_undefined_variable_error() -> None: - with pytest.raises(UndefinedVariableError): - raise UndefinedVariableError("x") + with pytest.raises(errors.UndefinedVariableError): + raise errors.UndefinedVariableError("x") def test_indexing_error() -> None: - with pytest.raises(IndexingError): - raise IndexingError() + with pytest.raises(errors.IndexingError): + raise errors.IndexingError() def test_pyperclip_exception() -> None: - with pytest.raises(PyperclipException): - raise PyperclipException() + with pytest.raises(errors.PyperclipException): + raise errors.PyperclipException() -@pytest.mark.skipif(not PD_LT_15 or not WINDOWS, reason="Feature moved in 1.5.0") +@pytest.mark.skipif(not WINDOWS, reason="Windows only") def test_pyperclip_windows_exception() -> None: - with pytest.raises(PyperclipWindowsException): - raise PyperclipWindowsException("message") + with pytest.raises(errors.PyperclipWindowsException): + raise errors.PyperclipWindowsException("message") def test_css_warning() -> None: - with pytest.warns(CSSWarning): - warnings.warn("", CSSWarning) + with pytest.warns(errors.CSSWarning): + warnings.warn("", errors.CSSWarning) def test_possible_data_loss_error() -> None: - with pytest.raises(PossibleDataLossError): - raise PossibleDataLossError() + with pytest.raises(errors.PossibleDataLossError): + raise errors.PossibleDataLossError() def test_closed_file_error() -> None: - with pytest.raises(ClosedFileError): - raise ClosedFileError() + with pytest.raises(errors.ClosedFileError): + raise errors.ClosedFileError() def test_incompatibility_warning() -> None: - with pytest.warns(IncompatibilityWarning): - warnings.warn("", IncompatibilityWarning) + with pytest.warns(errors.IncompatibilityWarning): + warnings.warn("", errors.IncompatibilityWarning) def test_attribute_conflict_warning() -> None: - with pytest.warns(AttributeConflictWarning): - warnings.warn("", AttributeConflictWarning) + with pytest.warns(errors.AttributeConflictWarning): + warnings.warn("", errors.AttributeConflictWarning) def test_database_error() -> None: - with pytest.raises(DatabaseError): - raise DatabaseError() + with pytest.raises(errors.DatabaseError): + raise errors.DatabaseError() def test_possible_precision_loss() -> None: - with pytest.warns(PossiblePrecisionLoss): - warnings.warn("", PossiblePrecisionLoss) + with pytest.warns(errors.PossiblePrecisionLoss): + warnings.warn("", errors.PossiblePrecisionLoss) def test_value_label_type_mismatch() -> None: - with pytest.warns(ValueLabelTypeMismatch): - warnings.warn("", ValueLabelTypeMismatch) + with pytest.warns(errors.ValueLabelTypeMismatch): + warnings.warn("", errors.ValueLabelTypeMismatch) def test_invalid_column_name() -> None: - with pytest.warns(InvalidColumnName): - warnings.warn("", InvalidColumnName) + with pytest.warns(errors.InvalidColumnName): + warnings.warn("", errors.InvalidColumnName) def test_categorical_conversion_warning() -> None: - with pytest.warns(CategoricalConversionWarning): - warnings.warn("", CategoricalConversionWarning) + with pytest.warns(errors.CategoricalConversionWarning): + warnings.warn("", errors.CategoricalConversionWarning) diff --git a/tests/test_io.py b/tests/test_io.py index 83c4596d9..fd37831ee 100644 --- a/tests/test_io.py +++ b/tests/test_io.py @@ -19,6 +19,7 @@ DataFrame, HDFStore, Series, + errors, read_clipboard, read_csv, read_excel, @@ -48,13 +49,11 @@ from typing_extensions import assert_type from tests import ( - PD_LT_15, + WINDOWS, check, ) from pandas.io.api import to_pickle -from pandas.io.clipboard import PyperclipException -from pandas.io.common import IOHandles from pandas.io.json._json import JsonReader from pandas.io.parsers import TextFileReader from pandas.io.pytables import ( @@ -69,14 +68,14 @@ CWD = os.path.split(os.path.abspath(__file__))[0] -@pytest.mark.skipif(PD_LT_15, reason="pandas 1.5.0 or later required") +@pytest.mark.skipif(WINDOWS, reason="ORC not available on windows") def test_orc(): with ensure_clean() as path: check(assert_type(DF.to_orc(path), None), type(None)) check(assert_type(read_orc(path), DataFrame), DataFrame) -@pytest.mark.skipif(PD_LT_15, reason="pandas 1.5.0 or later required") +@pytest.mark.skipif(WINDOWS, reason="ORC not available on windows") def test_orc_path(): with ensure_clean() as path: pathlib_path = Path(path) @@ -84,7 +83,7 @@ def test_orc_path(): check(assert_type(read_orc(pathlib_path), DataFrame), DataFrame) -@pytest.mark.skipif(PD_LT_15, reason="pandas 1.5.0 or later required") +@pytest.mark.skipif(WINDOWS, reason="ORC not available on windows") def test_orc_buffer(): with ensure_clean() as path: file_w = open(path, "wb") @@ -96,14 +95,14 @@ def test_orc_buffer(): file_r.close() -@pytest.mark.skipif(PD_LT_15, reason="pandas 1.5.0 or later required") +@pytest.mark.skipif(WINDOWS, reason="ORC not available on windows") def test_orc_columns(): with ensure_clean() as path: check(assert_type(DF.to_orc(path, index=False), None), type(None)) check(assert_type(read_orc(path, columns=["a"]), DataFrame), DataFrame) -@pytest.mark.skipif(PD_LT_15, reason="pandas 1.5.0 or later required") +@pytest.mark.skipif(WINDOWS, reason="ORC not available on windows") def test_orc_bytes(): check(assert_type(DF.to_orc(index=False), bytes), bytes) @@ -190,23 +189,6 @@ def test_read_stata_df(): check(assert_type(read_stata(path), pd.DataFrame), pd.DataFrame) -# Remove test when pandas 1.5.0 is released -@pytest.mark.skipif(not PD_LT_15, reason="Keyword only in 1.5.0") -def test_read_stata_iterator_positional(): - with ensure_clean() as path: - str_path = str(path) - DF.to_stata(str_path) - check( - assert_type( - read_stata( - str_path, False, False, None, False, False, None, False, 2, True - ), - StataReader, - ), - StataReader, - ) - - def test_read_stata_iterator(): with ensure_clean() as path: str_path = str(path) @@ -219,7 +201,7 @@ def test_read_stata_iterator(): def test_clipboard(): try: DF.to_clipboard() - except PyperclipException: + except errors.PyperclipException: pytest.skip("clipboard not available for testing") check(assert_type(read_clipboard(), DataFrame), DataFrame) check(assert_type(read_clipboard(iterator=False), DataFrame), DataFrame) @@ -229,7 +211,7 @@ def test_clipboard(): def test_clipboard_iterator(): try: DF.to_clipboard() - except PyperclipException: + except errors.PyperclipException: pytest.skip("clipboard not available for testing") check(assert_type(read_clipboard(iterator=True), TextFileReader), TextFileReader) check( @@ -661,9 +643,6 @@ def test_excel_writer(): with pd.ExcelWriter(path) as ew: check(assert_type(ew, pd.ExcelWriter), pd.ExcelWriter) DF.to_excel(ew, sheet_name="A") - if PD_LT_15: - # Remove after 1.5 and remove handles from ExcelWriter - check(assert_type(ew.handles, IOHandles[bytes]), IOHandles) check(assert_type(read_excel(path, sheet_name="A"), DataFrame), DataFrame) check(assert_type(read_excel(path), DataFrame), DataFrame) ef = pd.ExcelFile(path) diff --git a/tests/test_resampler.py b/tests/test_resampler.py index 1db5d7093..3d9dc3538 100644 --- a/tests/test_resampler.py +++ b/tests/test_resampler.py @@ -21,10 +21,7 @@ from pandas._typing import Scalar -from tests import ( - PD_LT_15, - check, -) +from tests import check DR = date_range("1999-1-1", periods=365, freq="D") DF_ = DataFrame(np.random.standard_normal((365, 1)), index=DR) @@ -301,11 +298,8 @@ def s2scalar(val: Series) -> float: check(S.resample("m").aggregate(np.sum), Series) check(S.resample("m").aggregate("sum"), Series) - if PD_LT_15: + with pytest.warns(FutureWarning, match="Not prepending group keys"): check(S.resample("m").aggregate(s2series), Series) - else: - with pytest.warns(FutureWarning, match="Not prepending group keys"): - check(S.resample("m").aggregate(s2series), Series) check(S.resample("m").aggregate(s2scalar), Series) check(S.resample("m").aggregate([np.mean]), DataFrame) check(S.resample("m").aggregate(["sum", np.mean]), DataFrame) @@ -325,11 +319,8 @@ def df2scalar(val: DataFrame) -> float: check(DF.resample("m").aggregate(np.sum), DataFrame) check(DF.resample("m").aggregate("sum"), DataFrame) - if PD_LT_15: + with pytest.warns(FutureWarning, match="Not prepending group keys"): check(DF.resample("m").aggregate(df2frame), DataFrame) - else: - with pytest.warns(FutureWarning, match="Not prepending group keys"): - check(DF.resample("m").aggregate(df2frame), DataFrame) check(DF.resample("m").aggregate(df2series), DataFrame) check(DF.resample("m").aggregate(df2scalar), DataFrame) check(DF.resample("m").aggregate([np.mean]), DataFrame) diff --git a/tests/test_series.py b/tests/test_series.py index fc8d12a1e..3d2d0831e 100644 --- a/tests/test_series.py +++ b/tests/test_series.py @@ -33,7 +33,6 @@ ) from tests import ( - PD_LT_15, TYPE_CHECKING_INVALID_USAGE, check, ) @@ -261,11 +260,8 @@ def test_types_rank() -> None: s.rank(method="min", pct=True) with pytest.warns(FutureWarning, match="Dropping of nuisance columns"): s.rank(method="dense", ascending=True) - if PD_LT_15: + with pytest.warns(FutureWarning, match="Calling Series.rank with numeric_only"): s.rank(method="first", numeric_only=True) - else: - with pytest.warns(FutureWarning, match="Calling Series.rank with numeric_only"): - s.rank(method="first", numeric_only=True) def test_types_mean() -> None: @@ -992,6 +988,7 @@ def test_string_accessors(): check(assert_type(s.str.rjust(80), pd.Series), pd.Series) check(assert_type(s.str.rpartition("p"), pd.DataFrame), pd.DataFrame) check(assert_type(s.str.rsplit("a"), pd.Series), pd.Series) + check(assert_type(s.str.rsplit("a", expand=True), pd.DataFrame), pd.DataFrame) check(assert_type(s.str.rstrip(), pd.Series), pd.Series) check(assert_type(s.str.slice(0, 4, 2), pd.Series), pd.Series) check(assert_type(s.str.slice_replace(0, 2, "XX"), pd.Series), pd.Series)