Skip to content

CLEAN: Align Groupby types #166

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

Merged
merged 1 commit into from
Jul 23, 2022
Merged
Show file tree
Hide file tree
Changes from all 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
12 changes: 1 addition & 11 deletions pandas-stubs/core/base.pyi
Original file line number Diff line number Diff line change
@@ -1,24 +1,18 @@
from __future__ import annotations

from typing import (
Callable,
Generic,
Literal,
)

import numpy as np
from pandas import (
DataFrame,
Index,
Series,
)
from pandas import Index
from pandas.core.accessor import DirNamesMixin
from pandas.core.arrays import ExtensionArray
from pandas.core.arrays.categorical import Categorical

from pandas._typing import (
NDFrameT,
Scalar,
SeriesAxisType,
)

Expand All @@ -35,10 +29,6 @@ class SpecificationError(GroupByError): ...
class SelectionMixin(Generic[NDFrameT]):
def ndim(self) -> int: ...
def __getitem__(self, key): ...
def aggregate(
self, func: Callable | None = ..., *args, **kwargs
) -> Scalar | Series | DataFrame: ...
agg = aggregate

class ShallowMixin: ...

Expand Down
10 changes: 7 additions & 3 deletions pandas-stubs/core/groupby/groupby.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,10 @@ from __future__ import annotations

from typing import Callable

from pandas.core.base import PandasObject
from pandas.core.base import (
PandasObject,
SelectionMixin,
)
from pandas.core.frame import DataFrame
from pandas.core.generic import NDFrame
from pandas.core.groupby import ops
Expand All @@ -14,14 +17,15 @@ from pandas._typing import (
AxisType,
FrameOrSeriesUnion,
KeysArgType,
NDFrameT,
)

class GroupByPlot(PandasObject):
def __init__(self, groupby) -> None: ...
def __call__(self, *args, **kwargs): ...
def __getattr__(self, name: str): ...

class _GroupBy(PandasObject, GroupByIndexingMixin):
class BaseGroupBy(PandasObject, SelectionMixin[NDFrameT], GroupByIndexingMixin):
level = ...
as_index = ...
keys = ...
Expand Down Expand Up @@ -63,7 +67,7 @@ class _GroupBy(PandasObject, GroupByIndexingMixin):
def get_group(self, name, obj: DataFrame | None = ...) -> DataFrame: ...
def apply(self, func: Callable, *args, **kwargs) -> FrameOrSeriesUnion: ...

class GroupBy(_GroupBy):
class GroupBy(BaseGroupBy[NDFrameT]):
def count(self) -> FrameOrSeriesUnion: ...
def mean(self, **kwargs) -> FrameOrSeriesUnion: ...
def median(self, **kwargs) -> FrameOrSeriesUnion: ...
Expand Down
4 changes: 2 additions & 2 deletions pandas-stubs/core/resample.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,12 @@ from __future__ import annotations

from pandas.core.base import ShallowMixin as ShallowMixin
from pandas.core.groupby.base import GroupByMixin as GroupByMixin
from pandas.core.groupby.groupby import _GroupBy
from pandas.core.groupby.groupby import BaseGroupBy
from pandas.core.groupby.grouper import Grouper as Grouper

from pandas._typing import FrameOrSeriesUnion

class Resampler(_GroupBy, ShallowMixin):
class Resampler(BaseGroupBy, ShallowMixin):
def __init__(
self, obj, groupby=..., axis: int = ..., kind=..., **kwargs
) -> None: ...
Expand Down