@@ -59,21 +59,32 @@ API changes
5959 same shaped objects whether the groups are unique or not. Revert this issue (:issue: `2893 `)
6060 with (:issue: `3596 `).
6161
62- .. ipython :: python
63-
64- df2 = pd.DataFrame([{" val1" : 1 , " val2" : 20 },
65- {" val1" : 1 , " val2" : 19 },
66- {" val1" : 1 , " val2" : 27 },
67- {" val1" : 1 , " val2" : 12 }])
68-
69- def func (dataf ):
70- return dataf[" val2" ] - dataf[" val2" ].mean()
71-
72- # squeezing the result frame to a series (because we have unique groups)
73- df2.groupby(" val1" , squeeze = True ).apply(func)
62+ .. code-block :: ipython
7463
75- # no squeezing (the default, and behavior in 0.10.1)
76- df2.groupby(" val1" ).apply(func)
64+ In [2]: df2 = pd.DataFrame([{"val1": 1, "val2": 20},
65+ ...: {"val1": 1, "val2": 19},
66+ ...: {"val1": 1, "val2": 27},
67+ ...: {"val1": 1, "val2": 12}])
68+
69+ In [3]: def func(dataf):
70+ ...: return dataf["val2"] - dataf["val2"].mean()
71+ ...:
72+
73+ In [4]: # squeezing the result frame to a series (because we have unique groups)
74+ ...: df2.groupby("val1", squeeze=True).apply(func)
75+ Out[4]:
76+ 0 0.5
77+ 1 -0.5
78+ 2 7.5
79+ 3 -7.5
80+ Name: 1, dtype: float64
81+
82+ In [5]: # no squeezing (the default, and behavior in 0.10.1)
83+ ...: df2.groupby("val1").apply(func)
84+ Out[5]:
85+ val2 0 1 2 3
86+ val1
87+ 1 0.5 -0.5 7.5 -7.5
7788
7889 - Raise on ``iloc `` when boolean indexing with a label based indexer mask
7990 e.g. a boolean Series, even with integer labels, will raise. Since ``iloc ``
0 commit comments