Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Data] Enable group over multiple keys in datasets #37832

Merged
merged 53 commits into from
Oct 27, 2023

Conversation

LeonLuttenberger
Copy link
Contributor

@LeonLuttenberger LeonLuttenberger commented Jul 26, 2023

Why are these changes needed?

This is a first draft into enabling grouping Ray datasets over multiple keys (i.e. passing a list of keys to .group()).

A new unit test test_groupby_multiple_keys_tabular_count showcases an example.

Depends on #37124 being merged first.

Related issue number

#25732

Checks

  • I've signed off every commit(by using the -s flag, i.e., git commit -s) in this PR.
  • I've run scripts/format.sh to lint the changes in this PR.
  • I've included any doc changes needed for https://docs.ray.io/en/master/.
    • I've added any new APIs to the API Reference. For example, if I added a
      method in Tune, I've added it in doc/source/tune/api/ under the
      corresponding .rst file.
  • I've made sure the tests are passing. Note that there might be a few flaky tests, see the recent failures at https://flakey-tests.ray.io/
  • Testing Strategy
    • Unit tests
    • Release tests
    • This PR is not tested :(

jaidisido and others added 30 commits July 4, 2023 10:55
Signed-off-by: Abdel Jaidi <jaidisido@gmail.com>
Signed-off-by: Abdel Jaidi <jaidisido@gmail.com>
Signed-off-by: Abdel Jaidi <jaidisido@gmail.com>
Signed-off-by: Anton Kukushkin <kukushkin.anton@gmail.com>
Signed-off-by: Anton Kukushkin <kukushkin.anton@gmail.com>
Signed-off-by: Anton Kukushkin <kukushkin.anton@gmail.com>
Signed-off-by: Anton Kukushkin <kukushkin.anton@gmail.com>
Signed-off-by: Anton Kukushkin <kukushkin.anton@gmail.com>
Signed-off-by: Anton Kukushkin <kukushkin.anton@gmail.com>
Signed-off-by: Anton Kukushkin <kukushkin.anton@gmail.com>
Signed-off-by: Anton Kukushkin <kukushkin.anton@gmail.com>
Signed-off-by: Anton Kukushkin <kukushkin.anton@gmail.com>
Copy link
Contributor

@jaidisido jaidisido left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Minor comments

python/ray/data/_internal/arrow_block.py Outdated Show resolved Hide resolved
python/ray/data/tests/test_all_to_all.py Outdated Show resolved Hide resolved
if ds_format == "pandas":
ds = _to_pandas(ds)

agg_ds = ds.groupby(["A", "B"]).count()
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is the .count() superfluous given that it's done again on the line below it?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The line below just checks the row count of the result of this operation. This amounts to just checking that there were indeed 6 groups in the original frame.

@raulchen raulchen self-assigned this Oct 10, 2023
Copy link
Contributor

@raulchen raulchen left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM overall. Sorry for the delay in reviews, as the 2.8 release was approaching.

python/ray/data/tests/test_all_to_all.py Outdated Show resolved Hide resolved
python/ray/data/_internal/arrow_block.py Show resolved Hide resolved
@raulchen raulchen merged commit 310409f into ray-project:master Oct 27, 2023
20 of 27 checks passed
@LeonLuttenberger LeonLuttenberger deleted the feat/ray-data-group-multi-keys branch October 27, 2023 18:51
@c21
Copy link
Contributor

c21 commented Oct 30, 2023

@LeonLuttenberger - thanks for the contribution! Shall we also add a unit test to test out map_groups()?

Technically after this PR, ds.groupby(keys).map_groups(fn) should also work on multiple columns. Thanks.

@LeonLuttenberger
Copy link
Contributor Author

Sounds good, I'm creating a PR to add the test for map_groups: #40828

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants