@@ -4413,10 +4413,12 @@ def pivot(self, index=None, columns=None, values=None):
44134413 list can contain any of the other types (except list).
44144414 Keys to group by on the pivot table column. If an array is passed,
44154415 it is being used as the same manner as column values.
4416- aggfunc : function or list of functions, default numpy.mean
4416+ aggfunc : function, list of functions, dict , default numpy.mean
44174417 If list of functions passed, the resulting pivot table will have
44184418 hierarchical columns whose top level are the function names
44194419 (inferred from the function objects themselves)
4420+ If dict is passed, the key is column to aggregate and value
4421+ is function or list of functions
44204422 fill_value : scalar, default None
44214423 Value to replace missing values with
44224424 margins : boolean, default False
@@ -4452,14 +4454,35 @@ def pivot(self, index=None, columns=None, values=None):
44524454 >>> table = pivot_table(df, values='D', index=['A', 'B'],
44534455 ... columns=['C'], aggfunc=np.sum)
44544456 >>> table
4455- ... # doctest: +NORMALIZE_WHITESPACE
44564457 C large small
44574458 A B
44584459 bar one 4.0 5.0
44594460 two 7.0 6.0
44604461 foo one 4.0 1.0
44614462 two NaN 6.0
44624463
4464+ >>> table = pivot_table(df, values='D', index=['A', 'B'],
4465+ ... columns=['C'], aggfunc=np.sum)
4466+ >>> table
4467+ C large small
4468+ A B
4469+ bar one 4.0 5.0
4470+ two 7.0 6.0
4471+ foo one 4.0 1.0
4472+ two NaN 6.0
4473+
4474+ >>> table = pivot_table(df, values=['D', 'E'], index=['A', 'C'],
4475+ ... aggfunc={'D': np.mean,
4476+ ... 'E': [min, max, np.mean]})
4477+ >>> table
4478+ D E
4479+ mean max median min
4480+ A C
4481+ bar large 5.500000 16 14.5 13
4482+ small 5.500000 15 14.5 14
4483+ foo large 2.000000 10 9.5 9
4484+ small 2.333333 12 11.0 8
4485+
44634486 Returns
44644487 -------
44654488 table : DataFrame
0 commit comments