Skip to content

Commit 9d0de41

Browse files
committed
TYP: add SeriesAggFuncType alias
1 parent b21c771 commit 9d0de41

File tree

3 files changed

+8
-7
lines changed

3 files changed

+8
-7
lines changed

pandas/_typing.py

+3-3
Original file line numberDiff line numberDiff line change
@@ -159,10 +159,10 @@
159159

160160
# types of `func` kwarg for DataFrame.aggregate and Series.aggregate
161161
AggFuncTypeBase = Union[Callable, str]
162-
AggFuncTypeDict = Dict[Hashable, Union[AggFuncTypeBase, List[AggFuncTypeBase]]]
162+
SeriesAggFuncType = Union[AggFuncTypeBase, List[AggFuncTypeBase]]
163+
AggFuncTypeDict = Dict[Hashable, SeriesAggFuncType]
163164
AggFuncType = Union[
164-
AggFuncTypeBase,
165-
List[AggFuncTypeBase],
165+
SeriesAggFuncType,
166166
AggFuncTypeDict,
167167
]
168168
AggObjType = Union[

pandas/core/apply.py

+2-1
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@
3232
AggObjType,
3333
Axis,
3434
NDFrameT,
35+
SeriesAggFuncType,
3536
npt,
3637
)
3738
from pandas.util._decorators import cache_readonly
@@ -1049,7 +1050,7 @@ class SeriesApply(NDFrameApply):
10491050
def __init__(
10501051
self,
10511052
obj: Series,
1052-
func: AggFuncTypeBase | list[AggFuncTypeBase],
1053+
func: SeriesAggFuncType,
10531054
convert_dtype: bool,
10541055
args,
10551056
kwargs,

pandas/core/series.py

+3-3
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,6 @@
3232
)
3333
from pandas._libs.lib import no_default
3434
from pandas._typing import (
35-
AggFuncTypeBase,
3635
ArrayLike,
3736
Axis,
3837
Dtype,
@@ -43,6 +42,7 @@
4342
Level,
4443
NaPosition,
4544
Renamer,
45+
SeriesAggFuncType,
4646
SingleManager,
4747
SortKind,
4848
StorageOptions,
@@ -4440,7 +4440,7 @@ def any(
44404440
)
44414441
def transform(
44424442
self,
4443-
func: AggFuncTypeBase | list[AggFuncTypeBase],
4443+
func: SeriesAggFuncType,
44444444
axis: Axis = 0,
44454445
*args,
44464446
**kwargs,
@@ -4454,7 +4454,7 @@ def transform(
44544454

44554455
def apply(
44564456
self,
4457-
func: AggFuncTypeBase | list[AggFuncTypeBase],
4457+
func: SeriesAggFuncType,
44584458
convert_dtype: bool = True,
44594459
args: tuple[Any, ...] = (),
44604460
**kwargs,

0 commit comments

Comments
 (0)