h2oai / h2oai/datatable

Support custom aggregate function in j expression

Open
#1,829 3 comments 0 reactions 0 assignees View on GitHub
Dominant language
C++
Stars
1.9k
Forks
164
Avg merge
7h 31m
Merged PRs (30d)
1

Description

Does it suppot the cutomize function for the aggregation in j? For example, if I need to obatin the length of each group, I would write an `anyfunction` to calculate it for each group and we might write something like this:
```python
dt_df=dt.Frame(X=[1,2,3,4,5,6],Y=[1,1,1,2,2,3])
def anyfunction(data):
return len(data)
dt_df[:,anyfunction(f.X),by(f.Y)]
````
In R, it is quite easy to implement, making use of the `.SD`:

```R
> dt=data.table(X=c(1,2,3,4,5,6),Y=c(1,1,1,2,2,3))
> anyfunction<-function(data){return(nrow(data))}
> dt[,anyfunction(.SD),by=Y]
Y V1
1: 1 3
2: 2 2
3: 3 1
```

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.