Skip to content

Commit

Permalink
Align DataFrame.apply signature with pandas (#9275)
Browse files Browse the repository at this point in the history
Aligns the function signature for `cudf.DataFrame.apply` with that of `pandas.DataFrame.apply`. This is needed so that dask can build on a common `apply` interface between backends among other reasons.

Authors:
  - https://github.com/brandon-b-miller

Approvers:
  - GALI PREM SAGAR (https://github.com/galipremsagar)

URL: #9275
  • Loading branch information
brandon-b-miller authored Sep 23, 2021
1 parent eaedf17 commit ced66b5
Showing 1 changed file with 15 additions and 2 deletions.
17 changes: 15 additions & 2 deletions python/cudf/cudf/core/dataframe.py
Original file line number Diff line number Diff line change
Expand Up @@ -4742,7 +4742,9 @@ def query(self, expr, local_dict=None):
boolmask = queryutils.query_execute(self, expr, callenv)
return self._apply_boolean_mask(boolmask)

def apply(self, func, axis=1):
def apply(
self, func, axis=1, raw=False, result_type=None, args=(), **kwargs
):
"""
Apply a function along an axis of the DataFrame.
Expand All @@ -4756,12 +4758,17 @@ def apply(self, func, axis=1):
----------
func : function
Function to apply to each row.
axis : {0 or 'index', 1 or 'columns'}, default 0
Axis along which the function is applied:
* 0 or 'index': apply function to each column.
Note: axis=0 is not yet supported.
* 1 or 'columns': apply function to each row.
raw: bool, default False
Not yet supported
result_type: {'expand', 'reduce', 'broadcast', None}, default None
Not yet supported
args: tuple
Not yet supported
Examples
--------
Expand Down Expand Up @@ -4910,6 +4917,12 @@ def apply(self, func, axis=1):
raise ValueError(
"DataFrame.apply currently only supports row wise ops"
)
if raw:
raise ValueError("The `raw` kwarg is not yet supported.")
if result_type is not None:
raise ValueError("The `result_type` kwarg is not yet supported.")
if args or kwargs:
raise ValueError("args and kwargs are not yet supported.")

return cudf.Series(func(self))

Expand Down

0 comments on commit ced66b5

Please sign in to comment.