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

[FEA] Support passing arguments to functions in groupby apply #10295

Closed
beckernick opened this issue Feb 15, 2022 · 1 comment · Fixed by #10682
Closed

[FEA] Support passing arguments to functions in groupby apply #10295

beckernick opened this issue Feb 15, 2022 · 1 comment · Fixed by #10682
Labels
cuDF (Python) Affects Python cuDF API. dask Dask issue feature request New feature or request

Comments

@beckernick
Copy link
Member

In pandas , I can pass arguments to a function used with groupby.apply. This is currently used internally to the Dask codebase (#10294) and also exposed in the public interface.

import dask.dataframe as dd
import pandas as pd
import dask_cudf
import cudfdf = pd.DataFrame({
    "a": [0,0,1,0,0,1,1,1,1,1],
    "b": [0,0.3,0,-4,0,-3,1,1,11,1],
    "c": [19,0,30,0,0,1,41,1,1,1],
})
gdf = cudf.from_pandas(df)
ddf = dd.from_pandas(df, 2)
gddf = dask_cudf.from_dask_dataframe(ddf)
​
def func(x, delta):
    return x + deltaprint(df.groupby("a").b.apply(func, 3))
print(ddf.groupby("a").b.apply(func, 3).compute())
0     3.0
1     3.3
2     3.0
3    -1.0
4     3.0
5     0.0
6     4.0
7     4.0
8    14.0
9     4.0
Name: b, dtype: float64
2     3.0
5     0.0
6     4.0
7     4.0
8    14.0
9     4.0
0     3.0
1     3.3
3    -1.0
4     3.0
Name: b, dtype: float64
/tmp/ipykernel_78541/1691277680.py:19: UserWarning: `meta` is not specified, inferred from partial data. Please provide `meta` if the result is unexpected.
  Before: .apply(func)
  After:  .apply(func, meta={'x': 'f8', 'y': 'f8'}) for dataframe result
  or:     .apply(func, meta=('x', 'f8'))            for series result
  print(ddf.groupby("a").b.apply(func, 3).compute())
@beckernick beckernick added feature request New feature or request cuDF (Python) Affects Python cuDF API. dask Dask issue labels Feb 15, 2022
@github-actions
Copy link

This issue has been labeled inactive-30d due to no recent activity in the past 30 days. Please close this issue if no further response or action is needed. Otherwise, please respond with a comment indicating any updates or changes to the original issue and/or confirm this issue still needs to be addressed. This issue will be labeled inactive-90d if there is no activity in the next 60 days.

@shwina shwina added this to Issue-Needs prioritizing in v22.06 Release via automation Mar 21, 2022
@shwina shwina moved this from Issue-Needs prioritizing to Issue-P1 in v22.06 Release Mar 21, 2022
v22.06 Release automation moved this from Issue-P1 to Done Apr 21, 2022
rapids-bot bot pushed a commit that referenced this issue Apr 21, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cuDF (Python) Affects Python cuDF API. dask Dask issue feature request New feature or request
Projects
No open projects
Development

Successfully merging a pull request may close this issue.

1 participant