Custom Group By Functions

Open
#3,296 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
5/5
Estimated time
Over a week
Newbie friendliness
25/100
Issue type
Feature
Clarity
Needs clarification
Activity status
Stale
Tech stack
numpy, python
Domain
data

Research direction

Start with the documented dt.count() grouped by('id') example in the issue and review the related quantiles request in issue #3165. Clarify how f.my_col is passed to custom functions such as np.percentile and whether grouped custom functions are supported; done means the expected grouped percentile behavior and supported function requirements are documented or implemented.

Written by the indexing model from the issue text.

Description

Following the documentation, you can get the count per group using:

x[:, { 'count': dt.count() }, by('id') ]

When trying to also include the percentile of a column by group, the np.percentile() function does not work

x[:, { 'count': dt.count(), 'percentile': np.percentile(f.my_col, 1) }, by('id') ]

How does the by operator handle the f.my_col selector? In R's data.table , you can basically apply any function that takes a vector as an input. so using np.percentile on the f.my_col would work. and the resulting table would be something like:

id count percentile
0 10 5
1 30 10
.... .... ....

i've seen this issue which has a similar request for quantiles: https://github.com/h2oai/datatable/issues/3165

How would I apply a custom function ( or one like np.percentile()) to the subset, or a column subset in the by?
do all functions need to be made "group-aware" to use by?
Does this make any custom-function by group impossible to do? Thanks!

Dominant language
C++
Stars
1.9k
Forks
164
PR merge metrics
No merged PRs in 30d

Getting set up

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from h2oai/datatable

All issues in h2oai/datatable

Similar issues

More C++ issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.