Skip to content

Commit 1515c4a

Browse files
authored
fix for missing types on NamedAgg (#111)
1 parent 0d99bf5 commit 1515c4a

File tree

2 files changed

+11
-3
lines changed

2 files changed

+11
-3
lines changed

pandas/_typing.pyi

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,14 @@ T = TypeVar('T')
4242
FuncType = Callable[..., Any]
4343
F = TypeVar("F", bound=FuncType)
4444

45+
AggFuncTypeBase = Union[Callable, str]
46+
AggFuncTypeDict = Dict[Hashable, Union[AggFuncTypeBase, List[AggFuncTypeBase]]]
47+
AggFuncType = Union[
48+
AggFuncTypeBase,
49+
List[AggFuncTypeBase],
50+
AggFuncTypeDict,
51+
]
52+
4553
num = Union[int, float]
4654
SeriesAxisType = Union[str, int, Literal["index", 0]] # Restricted subset of _AxisType for series
4755
AxisType = Union[str, int, Literal["columns", "index", 0, 1]]

pandas/core/groupby/generic.pyi

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
from matplotlib.axes import Axes as PlotAxes, SubplotBase as AxesSubplot
22
import numpy as np
33
import sys
4-
from pandas._typing import FrameOrSeries as FrameOrSeries, AxisType, Dtype, Level, F
4+
from pandas._typing import FrameOrSeries as FrameOrSeries, AxisType, Dtype, Level, F, AggFuncType
55
from pandas.core.frame import DataFrame as DataFrame
66
from pandas.core.groupby.groupby import GroupBy as GroupBy #, get_groupby as get_groupby
77
from pandas.core.groupby.grouper import Grouper as Grouper
@@ -13,8 +13,8 @@ else:
1313
from typing_extensions import Literal
1414

1515
class NamedAgg(NamedTuple):
16-
column = ...
17-
aggfunc = ...
16+
column: str = ...
17+
aggfunc: AggFuncType = ...
1818

1919
AggScalar = Union[str, Callable[..., Any]]
2020
ScalarResult = ...

0 commit comments

Comments
 (0)