Skip to content

Commit 2e10e9e

Browse files
committed
DOC: clarify GroupBy iteration example
1 parent d81171b commit 2e10e9e

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed

doc/source/user_guide/groupby.rst

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -255,6 +255,21 @@ the number of groups, which is the same as the length of the ``groups`` dictiona
255255
grouped.groups
256256
len(grouped)
257257
258+
Iterating over GroupBy
259+
----------------------
260+
261+
A ``GroupBy`` object can be iterated as ``(key, group)`` pairs,
262+
where each ``key`` represents the group name and ``group`` is a
263+
DataFrame containing the rows of that group.
264+
265+
Example:
266+
::
267+
268+
for key, group in df.groupby("A"):
269+
print(key)
270+
print(group)
271+
272+
258273

259274
.. _groupby.tabcompletion:
260275

0 commit comments

Comments
 (0)