NVIDIA / NVIDIA/cudf

[FEA] Rolling slope calculation with groupby

Open
#5,828 7 comments 0 reactions 0 assignees View on GitHub
feature request Python
Dominant language
C++
Stars
9.8k
Forks
1.1k
Avg merge
3d 6m
Merged PRs (30d)
278

Description

Hello.

I would like to calculate the rolling slope of y_value over x_value using cuML LinearRegression.

Sample data (cuDF dataframe):
```
| date | x_value | y_value |
| ------ | ------ | ---- |
| 2020-01-01 | 900 | 10 |
| 2020-01-01 | 905 | 15 |
| 2020-01-01 | 910 | 15 |
| 2020-01-01 | 915 | 15 |
| 2020-01-02 | 900 | 30 |
| 2020-01-02 | 905 | 40 |
| 2020-01-02 | 910 | 50 |
| ------ | ------ | ------ |
```
A simple function to use LinearRegression:
```
def RollingOLS(x, y):
lr = LinearRegression(fit_intercept = True, normalize = False, algorithm = 'svd')
reg = lr.fit(x, y)

return reg.coef_
```

What I would like to do:
```
data.groupby('date').rolling(2).apply(RollingOLS, x=x_value, y=y_value)
```

However, I am getting an error: ```NotImplementedError: Handling UDF with null values is not yet supported```. Is there any way to overcome this error? Thank you.

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.