Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

pandas 2.0 removals in core/arrays #932

Merged
merged 4 commits into from
May 30, 2024
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
79 changes: 7 additions & 72 deletions pandas-stubs/core/arrays/categorical.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,7 @@ from collections.abc import (
Callable,
Sequence,
)
from typing import (
Any,
Literal,
overload,
)
from typing import Any

import numpy as np
from pandas import Series
Expand Down Expand Up @@ -48,7 +44,6 @@ class Categorical(ExtensionArray):
def dtype(self) -> CategoricalDtype: ...
def astype(self, dtype: Dtype, copy: bool = ...) -> ArrayLike: ...
def size(self) -> int: ...
def itemsize(self) -> int: ...
def tolist(self) -> list[Scalar]: ...
to_list = ...
@classmethod
Expand All @@ -65,72 +60,16 @@ class Categorical(ExtensionArray):
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]
) -> None: ...
@overload
def set_categories(
self,
new_categories,
ordered=...,
rename: bool = ...,
inplace: Literal[False] = ...,
) -> Categorical: ...
@overload
def set_categories(
self, new_categories, ordered=..., rename: bool = ..., inplace: bool = ...
) -> Categorical | None: ...
@overload
def rename_categories(self, new_categories, inplace: Literal[True]) -> None: ...
@overload
def rename_categories(
self, new_categories, inplace: Literal[False] = ...
self, new_categories, ordered: bool | None = ..., rename: bool = ...
) -> Categorical: ...
@overload
def rename_categories(
self, new_categories, inplace: bool = ...
) -> Categorical | None: ...
@overload
def reorder_categories(
self, new_categories, ordered=..., *, inplace: Literal[True]
) -> None: ...
@overload
def rename_categories(self, new_categories) -> Categorical: ...
def reorder_categories(
self, new_categories, ordered=..., inplace: Literal[False] = ...
) -> Categorical: ...
@overload
def reorder_categories(
self, new_categories, ordered=..., inplace: bool = ...
) -> Categorical | None: ...
@overload
def add_categories(self, new_categories, inplace: Literal[True]) -> None: ...
@overload
def add_categories(
self, new_categories, inplace: Literal[False] = ...
) -> Categorical: ...
@overload
def add_categories(
self, new_categories, inplace: bool = ...
) -> Categorical | None: ...
@overload
def remove_categories(self, removals, inplace: Literal[True]) -> None: ...
@overload
def remove_categories(
self, removals, inplace: Literal[False] = ...
) -> Categorical: ...
@overload
def remove_categories(
self, removals, inplace: bool = ...
) -> Categorical | None: ...
@overload
def remove_unused_categories(self, inplace: Literal[True]) -> None: ...
@overload
def remove_unused_categories(
self, inplace: Literal[False] = ...
self, new_categories, ordered: bool | None = ...
) -> Categorical: ...
@overload
def remove_unused_categories(self, inplace: bool = ...) -> Categorical | None: ...
def add_categories(self, new_categories) -> Categorical: ...
def remove_categories(self, removals) -> Categorical: ...
def remove_unused_categories(self) -> Categorical: ...
def map(self, mapper): ...
def __eq__(self, other) -> bool: ...
def __ne__(self, other) -> bool: ...
Expand Down Expand Up @@ -161,23 +100,19 @@ class Categorical(ExtensionArray):
self, *, inplace: bool = ..., ascending: bool = ..., na_position: str = ...
): ...
def view(self, dtype=...): ...
def to_dense(self): ...
def fillna(self, value=..., method=..., limit=...): ...
def take(
self, indexer: TakeIndexer, *, allow_fill: bool = ..., fill_value=...
) -> Categorical: ...
def take_nd(self, indexer, allow_fill: bool = ..., fill_value=...): ...
def __len__(self) -> int: ...
def __iter__(self): ...
def __contains__(self, key) -> bool: ...
def __getitem__(self, key): ...
def __setitem__(self, key, value) -> None: ...
def min(self, *, skipna: bool = ...): ...
def max(self, *, skipna: bool = ...): ...
def mode(self, dropna: bool = ...): ...
def unique(self): ...
def equals(self, other): ...
def is_dtype_equal(self, other): ...
def describe(self): ...
def repeat(self, repeats, axis=...): ...
def isin(self, values): ...
Expand Down
2 changes: 0 additions & 2 deletions pandas-stubs/core/arrays/datetimes.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,6 @@ class DatetimeArray(DatetimeLikeArrayMixin, TimelikeOps, DatelikeOps):
second = ...
microsecond = ...
nanosecond = ...
weekofyear = ...
week = ...
dayofweek = ...
weekday = ...
dayofyear = ...
Expand Down
2 changes: 1 addition & 1 deletion pandas-stubs/core/groupby/generic.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -207,7 +207,7 @@ class DataFrameGroupBy(GroupBy[DataFrame], Generic[ByT]):
) -> DataFrame: ...
# error: overload 1 overlaps overload 2 because of different return types
@overload
def aggregate(self, func: Literal["size"]) -> Series: ... # type: ignore[overload-overlap] # pyright: ignore[reportOverlappingOverload]
def aggregate(self, func: Literal["size"]) -> Series: ... # type: ignore[overload-overlap]
@overload
def aggregate(
self,
Expand Down
31 changes: 16 additions & 15 deletions tests/test_plotting.py
Original file line number Diff line number Diff line change
Expand Up @@ -486,22 +486,23 @@ def test_plot_scatter(close_figures) -> None:
),
Axes,
)
check(
assert_type(
IRIS_DF.plot.scatter(x="SepalLength", y="SepalWidth", subplots=True),
npt.NDArray[np.object_],
),
np.ndarray,
)
check(
assert_type(
IRIS_DF.plot(
x="SepalLength", y="SepalWidth", subplots=True, kind="scatter"
with pytest.warns(UserWarning):
hamdanal marked this conversation as resolved.
Show resolved Hide resolved
check(
assert_type(
IRIS_DF.plot.scatter(x="SepalLength", y="SepalWidth", subplots=True),
npt.NDArray[np.object_],
),
npt.NDArray[np.object_],
),
np.ndarray,
)
np.ndarray,
)
check(
assert_type(
IRIS_DF.plot(
x="SepalLength", y="SepalWidth", subplots=True, kind="scatter"
),
npt.NDArray[np.object_],
),
np.ndarray,
)


def test_plot_keywords(close_figures):
Expand Down
Loading