Skip to content

Group rows of Table #160

@lars-reimann

Description

@lars-reimann

Is your feature request related to a problem?

There is currently no way to group the rows of a Table by a specific criteria.

Desired solution

  • New method group_by in Table
  • It should take one parameter key_selector: Callable[[Row], _T] that computes the grouping key for a row. _T is a type parameter.
  • The function should return a dict[T, Table]. The keys are the values computed by the key_selector the values are the rows mapped to that key combined to a Table

Example:

Table:

col1 col2
1 "a"
1 "b"
2 "c"
2 "d"
3 "e"

Key selector:

lambda row: row["col1"]

Expected result:

1:

col1 col2
1 "a"
1 "b"

2:

col1 col2
2 "c"
2 "d"

3:

col1 col2
3 "e"

Metadata

Metadata

Labels

releasedIncluded in a release

Type

No type

Projects

Status

✔️ Done

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions