Skip to content

Implement mappers for groupby method #1018

@nirizr

Description

@nirizr

Pandas's DataFrame and Series implementation of groupby accepts a mapper function as it's "by" parameter (named "Index" in dask).
If this by parameter is a callable, the data will be grouped according to the function's returned value.
The function is called with the dataframe indices.

Although it's not as important to me personally, the by parameter can be a variety of value types. lists of functions and mapping dictionaries are also supported.

A somewhat funny example can be:

def odd_or_even(i):
  return "Even" if i % 2 == 0 else "Odd"
df.groupby(odd_or_even).get_group("Even")

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions