Skip to content

Commit 12086b3

Browse files
TYPING/DOC: Move custom type to _typing and add whatsnew (#35220)
* remove \n from docstring * fix issue 17038 * revert change * revert change * move defined typing and add whatsnew
1 parent 331093e commit 12086b3

File tree

3 files changed

+10
-9
lines changed

3 files changed

+10
-9
lines changed

doc/source/whatsnew/v1.1.0.rst

+1
Original file line numberDiff line numberDiff line change
@@ -332,6 +332,7 @@ Other enhancements
332332
- :meth:`~Series.explode` now accepts ``ignore_index`` to reset the index, similarly to :meth:`pd.concat` or :meth:`DataFrame.sort_values` (:issue:`34932`).
333333
- :meth:`read_csv` now accepts string values like "0", "0.0", "1", "1.0" as convertible to the nullable boolean dtype (:issue:`34859`)
334334
- :class:`pandas.core.window.ExponentialMovingWindow` now supports a ``times`` argument that allows ``mean`` to be calculated with observations spaced by the timestamps in ``times`` (:issue:`34839`)
335+
- :meth:`DataFrame.agg` and :meth:`Series.agg` now accept named aggregation for renaming the output columns/indexes. (:issue:`26513`)
335336

336337
.. ---------------------------------------------------------------------------
337338

pandas/_typing.py

+8
Original file line numberDiff line numberDiff line change
@@ -96,3 +96,11 @@
9696
# DataFrame::sort_index, among others
9797
ValueKeyFunc = Optional[Callable[["Series"], Union["Series", AnyArrayLike]]]
9898
IndexKeyFunc = Optional[Callable[["Index"], Union["Index", AnyArrayLike]]]
99+
100+
# types of `func` kwarg for DataFrame.aggregate and Series.aggregate
101+
AggFuncTypeBase = Union[Callable, str]
102+
AggFuncType = Union[
103+
AggFuncTypeBase,
104+
List[AggFuncTypeBase],
105+
Dict[Label, Union[AggFuncTypeBase, List[AggFuncTypeBase]]],
106+
]

pandas/core/aggregation.py

+1-9
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
Union,
1818
)
1919

20-
from pandas._typing import Label
20+
from pandas._typing import AggFuncType, Label
2121

2222
from pandas.core.dtypes.common import is_dict_like, is_list_like
2323

@@ -26,14 +26,6 @@
2626
from pandas.core.indexes.api import Index
2727
from pandas.core.series import FrameOrSeriesUnion, Series
2828

29-
# types of `func` kwarg for DataFrame.aggregate and Series.aggregate
30-
AggFuncTypeBase = Union[Callable, str]
31-
AggFuncType = Union[
32-
AggFuncTypeBase,
33-
List[AggFuncTypeBase],
34-
Dict[Label, Union[AggFuncTypeBase, List[AggFuncTypeBase]]],
35-
]
36-
3729

3830
def reconstruct_func(
3931
func: Optional[AggFuncType], **kwargs,

0 commit comments

Comments
 (0)