Skip to content

Specify that both by and level should not be specified in groupby - GH40378 #47690

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

Closed
wants to merge 28 commits into from
Closed
Changes from 23 commits
Commits
Show all changes
28 commits
Select commit Hold shift + click to select a range
8c5fed9
updated the docstring in accordance with GH40378
GivyBoy Jul 12, 2022
25ddc0c
updated the docstring in accordance with GH40378
GivyBoy Jul 12, 2022
8ac46b7
updated the docstring in accordance with GH40378
GivyBoy Jul 12, 2022
28cb2bb
updated the docstring in accordance with GH40378
GivyBoy Jul 12, 2022
22241da
Merge https://github.com/GivyBoy/pandas-ag into first-proj
GivyBoy Jul 12, 2022
477bde6
updated the docstring in accordance with GH40378
GivyBoy Jul 12, 2022
1b39a25
updated the docstring in accordance with GH40378
GivyBoy Jul 12, 2022
53b122d
updated the docstring in accordance with GH40378
GivyBoy Jul 13, 2022
5e758c5
updated the docstring in accordance with GH40378
GivyBoy Jul 13, 2022
46af753
Revert "updated the docstring in accordance with GH40378"
GivyBoy Jul 13, 2022
cd1a30b
Revert "updated the docstring in accordance with GH40378"
GivyBoy Jul 13, 2022
a9c931b
updated the docstring in accordance with GH40378
GivyBoy Jul 13, 2022
7373884
updated the docstring in accordance with GH40378
GivyBoy Jul 13, 2022
56a6712
Merge branch 'pandas-dev:main' into main
GivyBoy Jul 13, 2022
30b1acf
updated the docstring in accordance with GH40378
GivyBoy Jul 13, 2022
6c3c46a
updated the docstring in accordance with GH40378
GivyBoy Jul 13, 2022
2f1b541
Merge branch 'pandas-dev:main' into main
GivyBoy Jul 13, 2022
ece2955
updated the docstring in accordance with GH40378
GivyBoy Jul 13, 2022
f5c0238
updated the docstring in accordance with GH40378
GivyBoy Jul 13, 2022
84c1136
updated the docstring in accordance with GH40378
GivyBoy Jul 13, 2022
992e0fd
Merge branch 'proj'
GivyBoy Jul 13, 2022
3be2d93
Merge branch 'main' of https://github.com/GivyBoy/pandas-ag
GivyBoy Jul 13, 2022
ffec05c
updated the docstring in accordance with GH40378
GivyBoy Jul 14, 2022
7d1ebda
updated the docstring in accordance with GH40378
GivyBoy Jul 14, 2022
f4c1944
updated the docstring in accordance with GH40378
GivyBoy Jul 14, 2022
5e1e142
updated the docstring in accordance with GH40378
GivyBoy Jul 14, 2022
5119a16
updated the docstring in accordance with GH40378
GivyBoy Jul 14, 2022
02d6e90
updated the docstring in accordance with GH40378
GivyBoy Jul 15, 2022
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
18 changes: 15 additions & 3 deletions doc/source/user_guide/groupby.rst
Original file line number Diff line number Diff line change
Expand Up @@ -274,15 +274,16 @@ the length of the ``groups`` dict, so it is largely just a convenience:
df
gb = df.groupby("gender")


.. ipython::
.. ipython:: python

@verbatim
In [1]: gb.<TAB> # noqa: E225, E999
:okexcept:
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why did this need to change?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The gb.<TAB> doesn't pass the tests when I try to build the documentation. I also added :okexcept: because of a build error.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you change this in a subsequent PR if this was failing locally to keep this PR scoped to the linked issue?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sure!

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks like these changes still exist in the latest commit

In [1]: gb.TAB # noqa: E225, E999
gb.agg gb.boxplot gb.cummin gb.describe gb.filter gb.get_group gb.height gb.last gb.median gb.ngroups gb.plot gb.rank gb.std gb.transform
gb.aggregate gb.count gb.cumprod gb.dtype gb.first gb.groups gb.hist gb.max gb.min gb.nth gb.prod gb.resample gb.sum gb.var
gb.apply gb.cummax gb.cumsum gb.fillna gb.gender gb.head gb.indices gb.mean gb.name gb.ohlc gb.quantile gb.size gb.tail gb.weight


.. _groupby.multiindex:

GroupBy with MultiIndex
Expand Down Expand Up @@ -345,6 +346,17 @@ Index level names may be supplied as keys.

More on the ``sum`` function and aggregation later.

When using ``.groupby()`` on a DatFrame with a MultiIndex, do not specify both ``by`` and ``level``.
The argument validation should be done in ``.groupby()``, using the name of the specific index.

.. ipython:: python

df = pd.DataFrame({"col1": ["a", "b", "c"]})
df.index = pd.MultiIndex.from_arrays([["a", "a", "b"],
[1, 2, 1]],
names=["x", "y"])
df.groupby(["col1", "x"])

Grouping DataFrame with Index levels and columns
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
A DataFrame may be grouped by a combination of columns and index levels by
Expand Down