Skip to content

Commit 25ddc0c

Browse files
committed
updated the docstring in accordance with GH40378
1 parent 2eca7e1 commit 25ddc0c

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

pandas/core/frame.py

+12
Original file line numberDiff line numberDiff line change
@@ -8332,6 +8332,18 @@ def update(
83328332
1 Falcon 370.0
83338333
2 Parrot 24.0
83348334
3 Parrot 26.0
8335+
8336+
When using ``.groupby()`` on a multiple index dataframe, do not specify both
8337+
``by`` and ``level``.
8338+
The argument validation should be done in ``.groupby()``,
8339+
using the name of the specific index.
8340+
8341+
>>> df = pandas.DataFrame({"col1": ["a", "b", "c"]})
8342+
>>> df.index = pandas.MultiIndex.from_arrays([["a", "a", "b"],
8343+
... [1, 2, 1]],
8344+
... names=["x", "y"])
8345+
>>> df.groupby(["col1", "x"]) # Fine
8346+
>>> df.groupby("col1", level=0) # TypeError
83358347
"""
83368348
)
83378349
@Appender(_shared_docs["groupby"] % _shared_doc_kwargs)

0 commit comments

Comments
 (0)