Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

DOC: fix deprecated groupby squeeze example in v0.12.0 whatsnew #34333

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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