Skip to content

Commit 5d8bb30

Browse files
DOC: fix deprecated groupby squeeze example in v0.12.0 whatsnew (#34333)
1 parent 833ce28 commit 5d8bb30

File tree

2 files changed

+31
-14
lines changed

2 files changed

+31
-14
lines changed

doc/source/reference/offset_frequency.rst

+6
Original file line numberDiff line numberDiff line change
@@ -878,6 +878,9 @@ Properties
878878
FY5253.normalize
879879
FY5253.rule_code
880880
FY5253.n
881+
FY5253.startingMonth
882+
FY5253.variation
883+
FY5253.weekday
881884

882885
Methods
883886
~~~~~~~
@@ -913,6 +916,9 @@ Properties
913916
FY5253Quarter.normalize
914917
FY5253Quarter.rule_code
915918
FY5253Quarter.n
919+
FY5253Quarter.startingMonth
920+
FY5253Quarter.variation
921+
FY5253Quarter.weekday
916922

917923
Methods
918924
~~~~~~~

doc/source/whatsnew/v0.12.0.rst

+25-14
Original file line numberDiff line numberDiff line change
@@ -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

Comments
 (0)