Skip to content

Commit a0d8f9c

Browse files
GH1614 Add more agg func methods for pivot_table (#1623)
* GH1614 Add more agg func methods for pivot_table * GH1614 PR Feedback * GH1614 PR Feedback * GH1614 PR Feedback * GH1614 Extend testing for DataFrame.pivot_table and pd.pivot_table * GH1614 PR Feedback * GH1614 PR Feedback
1 parent 2c83c1f commit a0d8f9c

3 files changed

Lines changed: 976 additions & 18 deletions

File tree

pandas-stubs/core/reshape/pivot.pyi

Lines changed: 20 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ from typing import (
1515
import numpy as np
1616
import pandas as pd
1717
from pandas.core.frame import DataFrame
18+
from pandas.core.groupby.base import ReductionKernelType
1819
from pandas.core.groupby.grouper import Grouper
1920
from pandas.core.indexes.base import Index
2021
from pandas.core.series import Series
@@ -30,23 +31,25 @@ from pandas._typing import (
3031
)
3132

3233
_PivotAggCallable: TypeAlias = Callable[[Series], ScalarT]
33-
_PivotAggFunc: TypeAlias = _PivotAggCallable[ScalarT] | np.ufunc | str
34-
35-
# TODO: pandas-dev/pandas-stubs#1614 improve list of available functions for aggfunc
36-
# | Literal[
37-
# "mean",
38-
# "sum",
39-
# "count",
40-
# "min",
41-
# "max",
42-
# "median",
43-
# "std",
44-
# "var",
45-
# "nunique",
46-
# "ohlc",
47-
# "quantile",
48-
# "rank",
49-
# ]
34+
_PivotAggFunc: TypeAlias = (
35+
_PivotAggCallable[ScalarT]
36+
| np.ufunc
37+
| ReductionKernelType
38+
| Literal[
39+
"ohlc",
40+
"quantile",
41+
"bfill",
42+
"cummax",
43+
"cummin",
44+
"cumprod",
45+
"cumsum",
46+
"diff",
47+
"ffill",
48+
"pct_change",
49+
"rank",
50+
"shift",
51+
]
52+
)
5053

5154
_PivotAggFuncTypes: TypeAlias = (
5255
_PivotAggFunc[ScalarT]

0 commit comments

Comments
 (0)