Skip to content

Commit

Permalink
Merge 205740d into b9d6770
Browse files Browse the repository at this point in the history
  • Loading branch information
raybellwaves committed Feb 23, 2020
2 parents b9d6770 + 205740d commit 0531368
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions docs/source/dataframe-groupby.rst
Expand Up @@ -207,3 +207,16 @@ Finally, we create and use the aggregation
a
a 2
b 4
Another example of a custom aggregation is the Dask DataFrame version of
Pandas' ``groupby('g').agg(list)``:

.. code-block:: python
>>> import itertools as it
>>> collect_list = dd.Aggregation(
... name="collect_list",
... chunk=lambda s: s.apply(list),
... agg=lambda s0: s0.apply(lambda chunks: list(it.chain.from_iterable(chunks))),
... )
>>> df.groupby('g').agg(collect_list)

0 comments on commit 0531368

Please sign in to comment.