Skip to content

Commit

Permalink
DOC: fix deprecated groupby squeeze example in v0.12.0 whatsnew (#34333)
Browse files Browse the repository at this point in the history
  • Loading branch information
jorisvandenbossche authored May 23, 2020
1 parent 833ce28 commit 5d8bb30
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 14 deletions.
6 changes: 6 additions & 0 deletions doc/source/reference/offset_frequency.rst
Original file line number Diff line number Diff line change
Expand Up @@ -878,6 +878,9 @@ Properties
FY5253.normalize
FY5253.rule_code
FY5253.n
FY5253.startingMonth
FY5253.variation
FY5253.weekday

Methods
~~~~~~~
Expand Down Expand Up @@ -913,6 +916,9 @@ Properties
FY5253Quarter.normalize
FY5253Quarter.rule_code
FY5253Quarter.n
FY5253Quarter.startingMonth
FY5253Quarter.variation
FY5253Quarter.weekday

Methods
~~~~~~~
Expand Down
39 changes: 25 additions & 14 deletions doc/source/whatsnew/v0.12.0.rst
Original file line number Diff line number Diff line change
Expand Up @@ -59,21 +59,32 @@ API changes
same shaped objects whether the groups are unique or not. Revert this issue (:issue:`2893`)
with (:issue:`3596`).

.. ipython:: python
df2 = pd.DataFrame([{"val1": 1, "val2": 20},
{"val1": 1, "val2": 19},
{"val1": 1, "val2": 27},
{"val1": 1, "val2": 12}])
def func(dataf):
return dataf["val2"] - dataf["val2"].mean()
# squeezing the result frame to a series (because we have unique groups)
df2.groupby("val1", squeeze=True).apply(func)
.. code-block:: ipython
# no squeezing (the default, and behavior in 0.10.1)
df2.groupby("val1").apply(func)
In [2]: df2 = pd.DataFrame([{"val1": 1, "val2": 20},
...: {"val1": 1, "val2": 19},
...: {"val1": 1, "val2": 27},
...: {"val1": 1, "val2": 12}])
In [3]: def func(dataf):
...: return dataf["val2"] - dataf["val2"].mean()
...:
In [4]: # squeezing the result frame to a series (because we have unique groups)
...: df2.groupby("val1", squeeze=True).apply(func)
Out[4]:
0 0.5
1 -0.5
2 7.5
3 -7.5
Name: 1, dtype: float64
In [5]: # no squeezing (the default, and behavior in 0.10.1)
...: df2.groupby("val1").apply(func)
Out[5]:
val2 0 1 2 3
val1
1 0.5 -0.5 7.5 -7.5
- Raise on ``iloc`` when boolean indexing with a label based indexer mask
e.g. a boolean Series, even with integer labels, will raise. Since ``iloc``
Expand Down

0 comments on commit 5d8bb30

Please sign in to comment.