Skip to content

Commit 8a98007

Browse files
author
Chang She
committed
DOC: groupby drop duplicate index #1312
1 parent 4eb91f4 commit 8a98007

File tree

1 file changed

+19
-0
lines changed

1 file changed

+19
-0
lines changed

doc/source/groupby.rst

+19
Original file line numberDiff line numberDiff line change
@@ -118,6 +118,25 @@ columns:
118118

119119
In [5]: grouped = df.groupby(get_letter_type, axis=1)
120120

121+
Starting with 0.8, pandas Index objects now supports duplicate values. If a
122+
non-unique index is used as the group key in a groupby operation, all values for
123+
the same index value will be considered to be in one group and thus the output
124+
of aggregation functions will only contain unique index values:
125+
126+
.. ipython:: python
127+
128+
lst = [1, 2, 3, 1, 2, 3]
129+
130+
s = Series([1, 2, 3, 10, 20, 30], lst)
131+
132+
grouped = s.groupby(level=0)
133+
134+
grouped.first()
135+
136+
grouped.last()
137+
138+
grouped.sum()
139+
121140
Note that **no splitting occurs** until it's needed. Creating the GroupBy object
122141
only verifies that you've passed a valid mapping.
123142

0 commit comments

Comments
 (0)