Grouping Series by its values in Pandas
To group the values of a Series, use the
Here, note the following:
we see the value 6 corresponding to the index 3 because we are summing up all occurrences of the value of 3 (i.e. 3+3=6).
s.groupby(s)is slightly awkward - but we need to pass in
sas the argument since the
groupby(~)groups by the index instead of values by default.
SeriesGroupByobject, which has aggregate functions such as