Skip to content

Commit 2b64e3b

Browse files
GH1294 PR feedback
1 parent 95e7f11 commit 2b64e3b

File tree

5 files changed

+43
-49
lines changed

5 files changed

+43
-49
lines changed

pandas-stubs/core/frame.pyi

Lines changed: 34 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -164,7 +164,6 @@ from pandas._typing import (
164164

165165
from pandas.io.formats.style import Styler
166166
from pandas.plotting import PlotAccessor
167-
from pandas.plotting._core import hist_frame
168167

169168
class _iLocIndexerFrame(_iLocIndexer, Generic[_T]):
170169
@overload
@@ -309,7 +308,7 @@ else:
309308
@overload
310309
def __getitem__(self, key: Hashable) -> Series: ...
311310

312-
AstypeArgExt: TypeAlias = (
311+
_AstypeArgExt: TypeAlias = (
313312
AstypeArg
314313
| Literal[
315314
"number",
@@ -322,7 +321,7 @@ AstypeArgExt: TypeAlias = (
322321
"datetime64[ns]",
323322
]
324323
)
325-
AstypeArgExtList: TypeAlias = AstypeArgExt | list[AstypeArgExt]
324+
_AstypeArgExtList: TypeAlias = _AstypeArgExt | list[_AstypeArgExt]
326325

327326
class DataFrame(NDFrame, OpsMixin, _GetItemHack):
328327

@@ -769,11 +768,11 @@ class DataFrame(NDFrame, OpsMixin, _GetItemHack):
769768
) -> Scalar | np.ndarray | Self | Series: ...
770769
@overload
771770
def select_dtypes(
772-
self, include: StrDtypeArg, exclude: AstypeArgExtList | None = ...
771+
self, include: StrDtypeArg, exclude: _AstypeArgExtList | None = ...
773772
) -> Never: ...
774773
@overload
775774
def select_dtypes(
776-
self, include: AstypeArgExtList | None, exclude: StrDtypeArg
775+
self, include: _AstypeArgExtList | None, exclude: StrDtypeArg
777776
) -> Never: ...
778777
@overload
779778
def select_dtypes(self, exclude: StrDtypeArg) -> Never: ...
@@ -782,19 +781,19 @@ class DataFrame(NDFrame, OpsMixin, _GetItemHack):
782781
@overload
783782
def select_dtypes(
784783
self,
785-
include: AstypeArgExtList,
786-
exclude: AstypeArgExtList | None = ...,
784+
include: _AstypeArgExtList,
785+
exclude: _AstypeArgExtList | None = ...,
787786
) -> Self: ...
788787
@overload
789788
def select_dtypes(
790789
self,
791-
include: AstypeArgExtList | None,
792-
exclude: AstypeArgExtList,
790+
include: _AstypeArgExtList | None,
791+
exclude: _AstypeArgExtList,
793792
) -> Self: ...
794793
@overload
795794
def select_dtypes(
796795
self,
797-
exclude: AstypeArgExtList,
796+
exclude: _AstypeArgExtList,
798797
) -> Self: ...
799798
def insert(
800799
self,
@@ -1330,17 +1329,15 @@ class DataFrame(NDFrame, OpsMixin, _GetItemHack):
13301329
def stack(
13311330
self,
13321331
level: IndexLabel = ...,
1333-
dropna: _bool = ...,
1334-
sort: _bool = ...,
1335-
future_stack: Literal[False] = ...,
1332+
future_stack: Literal[True] = ...,
13361333
) -> Self | Series: ...
13371334
@overload
13381335
def stack(
13391336
self,
13401337
level: IndexLabel = ...,
1341-
dropna: _NoDefaultDoNotUse = ...,
1342-
sort: _NoDefaultDoNotUse = ...,
1343-
future_stack: Literal[True] = ...,
1338+
dropna: _bool = ...,
1339+
sort: _bool = ...,
1340+
future_stack: Literal[False] = ...,
13441341
) -> Self | Series: ...
13451342
def explode(
13461343
self, column: Sequence[Hashable], ignore_index: _bool = ...
@@ -1376,9 +1373,9 @@ class DataFrame(NDFrame, OpsMixin, _GetItemHack):
13761373
**kwargs: Any,
13771374
) -> Self: ...
13781375
@overload
1379-
def aggregate(
1376+
def aggregate( # pyright: ignore[reportOverlappingOverload]
13801377
self,
1381-
func: AggFuncTypeBase | AggFuncTypeDictSeries = ...,
1378+
func: AggFuncTypeBase | AggFuncTypeDictSeries,
13821379
axis: Axis = ...,
13831380
**kwargs: Any,
13841381
) -> Series: ...
@@ -1592,7 +1589,7 @@ class DataFrame(NDFrame, OpsMixin, _GetItemHack):
15921589
method: Literal["pearson", "kendall", "spearman"] = ...,
15931590
numeric_only: _bool = ...,
15941591
) -> Series: ...
1595-
def count(self, axis: Axis = ..., numeric_only: _bool = ...) -> Self: ...
1592+
def count(self, axis: Axis = ..., numeric_only: _bool = ...) -> Series[int]: ...
15961593
def nunique(self, axis: Axis = ..., dropna: bool = ...) -> Series: ...
15971594
def idxmax(
15981595
self, axis: Axis = ..., skipna: _bool = ..., numeric_only: _bool = ...
@@ -1637,7 +1634,24 @@ class DataFrame(NDFrame, OpsMixin, _GetItemHack):
16371634
def isin(self, values: Iterable | Series | DataFrame | dict) -> Self: ...
16381635
@property
16391636
def plot(self) -> PlotAccessor: ...
1640-
hist = hist_frame
1637+
def hist(
1638+
self,
1639+
column: _str | list[_str] | None = ...,
1640+
by: _str | ListLike | None = ...,
1641+
grid: _bool = ...,
1642+
xlabelsize: float | str | None = ...,
1643+
xrot: float | None = ...,
1644+
ylabelsize: float | str | None = ...,
1645+
yrot: float | None = ...,
1646+
ax: PlotAxes | None = ...,
1647+
sharex: _bool = ...,
1648+
sharey: _bool = ...,
1649+
figsize: tuple[float, float] | None = ...,
1650+
layout: tuple[int, int] | None = ...,
1651+
bins: int | list = ...,
1652+
backend: _str | None = ...,
1653+
**kwargs: Any,
1654+
): ...
16411655
def boxplot(
16421656
self,
16431657
column: _str | list[_str] | None = ...,

pandas-stubs/core/indexes/multi.pyi

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -45,28 +45,28 @@ class MultiIndex(Index):
4545
cls,
4646
arrays: Sequence[Axes],
4747
sortorder: int | None = ...,
48-
names: SequenceNotStr[Hashable] | None = ...,
48+
names: SequenceNotStr[Hashable] = ...,
4949
) -> Self: ...
5050
@classmethod
5151
def from_tuples(
5252
cls,
5353
tuples: Iterable[tuple[Hashable, ...]],
5454
sortorder: int | None = ...,
55-
names: SequenceNotStr[Hashable] | None = ...,
55+
names: SequenceNotStr[Hashable] = ...,
5656
) -> Self: ...
5757
@classmethod
5858
def from_product(
5959
cls,
6060
iterables: Sequence[SequenceNotStr[Hashable] | pd.Series | pd.Index],
6161
sortorder: int | None = ...,
62-
names: SequenceNotStr[Hashable] | None = ...,
62+
names: SequenceNotStr[Hashable] = ...,
6363
) -> Self: ...
6464
@classmethod
6565
def from_frame(
6666
cls,
6767
df: pd.DataFrame,
6868
sortorder: int | None = ...,
69-
names: SequenceNotStr[Hashable] | None = ...,
69+
names: SequenceNotStr[Hashable] = ...,
7070
) -> Self: ...
7171
@property
7272
def shape(self): ...
@@ -77,7 +77,7 @@ class MultiIndex(Index):
7777
def codes(self): ...
7878
def set_codes(self, codes, *, level=..., verify_integrity: bool = ...): ...
7979
def copy( # type: ignore[override] # pyright: ignore[reportIncompatibleMethodOverride] # pyrefly: ignore
80-
self, names: SequenceNotStr[Hashable] = ..., deep: bool = ..., name: None = ...
80+
self, names: SequenceNotStr[Hashable] = ..., deep: bool = ...
8181
) -> Self: ...
8282
def view(self, cls=...): ...
8383
def __contains__(self, key) -> bool: ...

pandas-stubs/core/series.pyi

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -937,7 +937,7 @@ class Series(IndexOpsMixin[S1], NDFrame):
937937
self, i: Level = ..., j: Level = ..., copy: _bool = ...
938938
) -> Series[S1]: ...
939939
def reorder_levels(self, order: list) -> Series[S1]: ...
940-
def explode(self, ignore_index: bool = ...) -> Series[S1]: ...
940+
def explode(self, ignore_index: _bool = ...) -> Series[S1]: ...
941941
def unstack(
942942
self,
943943
level: IndexLabel = ...,
@@ -1680,6 +1680,7 @@ class Series(IndexOpsMixin[S1], NDFrame):
16801680
) -> TimedeltaSeries: ...
16811681
@overload
16821682
def __rmul__(self, other: num | _ListLike | Series) -> Series: ...
1683+
def __rmatmul__(self, other: num | _ListLike | Series[S1]) -> Series[S1]: ...
16831684
def __rpow__(self, other: num | _ListLike | Series[S1]) -> Series[S1]: ...
16841685
# ignore needed for mypy as we want different results based on the arguments
16851686
@overload # type: ignore[override]
@@ -1835,7 +1836,7 @@ class Series(IndexOpsMixin[S1], NDFrame):
18351836
def expanding(
18361837
self,
18371838
min_periods: int = ...,
1838-
axis: Axes = ...,
1839+
axis: Literal[0] = ...,
18391840
method: CalculationMethod = ...,
18401841
) -> Expanding[Series]: ...
18411842
def floordiv(

pandas-stubs/plotting/_core.pyi

Lines changed: 0 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -435,23 +435,3 @@ class PlotAccessor:
435435
) -> npt.NDArray[np.object_]: ...
436436

437437
density = kde
438-
439-
def hist_frame(
440-
data: DataFrame,
441-
column: Axes | None = None,
442-
by=None,
443-
grid: bool = True,
444-
xlabelsize: int | None = None,
445-
xrot: float | None = None,
446-
ylabelsize: int | None = None,
447-
yrot: float | None = None,
448-
ax=None,
449-
sharex: bool = False,
450-
sharey: bool = False,
451-
figsize: tuple[int, int] | None = None,
452-
layout: tuple[int, int] | None = None,
453-
bins: int | Sequence[int] = 10,
454-
backend: str | None = None,
455-
legend: bool = False,
456-
**kwargs,
457-
) -> Axes | list[Axes]: ...

tests/test_series.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1520,8 +1520,7 @@ def test_types_bfill() -> None:
15201520

15211521
def test_types_ewm() -> None:
15221522
s1 = pd.Series([1, 2, 3])
1523-
if TYPE_CHECKING_INVALID_USAGE:
1524-
check(
1523+
check(
15251524
assert_type(
15261525
s1.ewm(com=0.3, min_periods=0, adjust=False, ignore_na=True),
15271526
"ExponentialMovingWindow[pd.Series]",

0 commit comments

Comments
 (0)