Example 1 and Example 2 are both incorrect for 'GroupBy.apply' functon in document.
>>> df = pd.DataFrame({'A': 'a a b'.split(), 'B': [1,2,3], 'C': [4,6, 5]})
>>> g = df.groupby('A')
The following changes should be made.
Example1
>>> g[['B','C']].apply(lambda x: x / x.sum())
B C
0 0.333333 0.4
1 0.666667 0.6
2 1.000000 1.0
Example2
>>> g[['B','C']].apply(lambda x: x.max() - x.min())
B C
A
a 1 2
b 0 0
Comment From: jorisvandenbossche
@ZhuBaohe Thanks for the report! You are correct. It was recently already reported here: https://github.com/pandas-dev/pandas/issues/19337, so closing this issue.