@@ -75,8 +75,6 @@ from pandas._typing import (
7575
7676from pandas .plotting import PlotAccessor
7777
78- _GroupByT = TypeVar ("_GroupByT" , bound = GroupBy )
79-
8078_KeysArgType : TypeAlias = (
8179 Hashable
8280 | list [Hashable ]
@@ -91,67 +89,6 @@ _ResamplerGroupBy: TypeAlias = (
9189 | TimedeltaIndexResamplerGroupby [NDFrameT ]
9290)
9391
94- # GroupByPlot does not really inherit from PlotAccessor but it delegates
95- # to it using __call__ and __getattr__. We lie here to avoid repeating the
96- # whole stub of PlotAccessor
97- @final
98- class GroupByPlot (PlotAccessor , Generic [_GroupByT ]):
99- def __init__ (self , groupby : _GroupByT ) -> None : ...
100- # The following methods are inherited from the fake parent class PlotAccessor
101- # def __call__(self, *args, **kwargs): ...
102- # def __getattr__(self, name: str): ...
103-
104- class BaseGroupBy (SelectionMixin [NDFrameT ], GroupByIndexingMixin ):
105- axis : AxisInt
106- grouper : ops .BaseGrouper
107- keys : _KeysArgType | None
108- level : IndexLabel | None
109- group_keys : bool
110- @final
111- def __len__ (self ) -> int : ...
112- @final
113- def __repr__ (self ) -> str : ... # noqa: PYI029 __repr__ here is final
114- @final
115- @property
116- def groups (self ) -> dict [Hashable , Index ]: ...
117- @final
118- @property
119- def ngroups (self ) -> int : ...
120- @final
121- @property
122- def indices (self ) -> dict [Hashable , Index | npt .NDArray [np .int_ ] | list [int ]]: ...
123- @overload
124- def pipe (
125- self ,
126- func : Callable [Concatenate [Self , P ], T ],
127- * args : P .args ,
128- ** kwargs : P .kwargs ,
129- ) -> T : ...
130- @overload
131- def pipe (
132- self ,
133- func : tuple [Callable [..., T ], str ],
134- * args : Any ,
135- ** kwargs : Any ,
136- ) -> T : ...
137- @final
138- def get_group (self , name , obj : NDFrameT | None = ...) -> NDFrameT : ...
139- @final
140- def __iter__ (self ) -> Iterator [tuple [Hashable , NDFrameT ]]: ...
141- @overload
142- def __getitem__ (self : BaseGroupBy [DataFrame ], key : Scalar ) -> generic .SeriesGroupBy : ... # type: ignore[overload-overlap] # pyright: ignore[reportOverlappingOverload]
143- @overload
144- def __getitem__ (
145- self : BaseGroupBy [DataFrame ], key : Iterable [Hashable ]
146- ) -> generic .DataFrameGroupBy : ...
147- @overload
148- def __getitem__ (
149- self : BaseGroupBy [Series [S1 ]],
150- idx : list [str ] | Index | Series [S1 ] | MaskType | tuple [Hashable | slice , ...],
151- ) -> generic .SeriesGroupBy : ...
152- @overload
153- def __getitem__ (self : BaseGroupBy [Series [S1 ]], idx : Scalar ) -> S1 : ...
154-
15592class GroupBy (BaseGroupBy [NDFrameT ]):
15693 as_index : bool
15794 sort : bool
@@ -393,3 +330,66 @@ class GroupBy(BaseGroupBy[NDFrameT]):
393330 weights : Sequence | Series | None = ...,
394331 random_state : RandomState | None = ...,
395332 ) -> NDFrameT : ...
333+
334+ _GroupByT = TypeVar ("_GroupByT" , bound = GroupBy )
335+
336+ # GroupByPlot does not really inherit from PlotAccessor but it delegates
337+ # to it using __call__ and __getattr__. We lie here to avoid repeating the
338+ # whole stub of PlotAccessor
339+ @final
340+ class GroupByPlot (PlotAccessor , Generic [_GroupByT ]):
341+ def __init__ (self , groupby : _GroupByT ) -> None : ...
342+ # The following methods are inherited from the fake parent class PlotAccessor
343+ # def __call__(self, *args, **kwargs): ...
344+ # def __getattr__(self, name: str): ...
345+
346+ class BaseGroupBy (SelectionMixin [NDFrameT ], GroupByIndexingMixin ):
347+ axis : AxisInt
348+ grouper : ops .BaseGrouper
349+ keys : _KeysArgType | None
350+ level : IndexLabel | None
351+ group_keys : bool
352+ @final
353+ def __len__ (self ) -> int : ...
354+ @final
355+ def __repr__ (self ) -> str : ... # noqa: PYI029 __repr__ here is final
356+ @final
357+ @property
358+ def groups (self ) -> dict [Hashable , Index ]: ...
359+ @final
360+ @property
361+ def ngroups (self ) -> int : ...
362+ @final
363+ @property
364+ def indices (self ) -> dict [Hashable , Index | npt .NDArray [np .int_ ] | list [int ]]: ...
365+ @overload
366+ def pipe (
367+ self ,
368+ func : Callable [Concatenate [Self , P ], T ],
369+ * args : P .args ,
370+ ** kwargs : P .kwargs ,
371+ ) -> T : ...
372+ @overload
373+ def pipe (
374+ self ,
375+ func : tuple [Callable [..., T ], str ],
376+ * args : Any ,
377+ ** kwargs : Any ,
378+ ) -> T : ...
379+ @final
380+ def get_group (self , name , obj : NDFrameT | None = ...) -> NDFrameT : ...
381+ @final
382+ def __iter__ (self ) -> Iterator [tuple [Hashable , NDFrameT ]]: ...
383+ @overload
384+ def __getitem__ (self : BaseGroupBy [DataFrame ], key : Scalar ) -> generic .SeriesGroupBy : ... # type: ignore[overload-overlap] # pyright: ignore[reportOverlappingOverload]
385+ @overload
386+ def __getitem__ (
387+ self : BaseGroupBy [DataFrame ], key : Iterable [Hashable ]
388+ ) -> generic .DataFrameGroupBy : ...
389+ @overload
390+ def __getitem__ (
391+ self : BaseGroupBy [Series [S1 ]],
392+ idx : list [str ] | Index | Series [S1 ] | MaskType | tuple [Hashable | slice , ...],
393+ ) -> generic .SeriesGroupBy : ...
394+ @overload
395+ def __getitem__ (self : BaseGroupBy [Series [S1 ]], idx : Scalar ) -> S1 : ...
0 commit comments