From ced66b568a837572daf5bc0a3c5c7b258cc4ba34 Mon Sep 17 00:00:00 2001 From: brandon-b-miller <53796099+brandon-b-miller@users.noreply.github.com> Date: Wed, 22 Sep 2021 21:34:27 -0500 Subject: [PATCH] Align `DataFrame.apply` signature with pandas (#9275) 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: https://github.com/rapidsai/cudf/pull/9275 --- python/cudf/cudf/core/dataframe.py | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/python/cudf/cudf/core/dataframe.py b/python/cudf/cudf/core/dataframe.py index 1143f85a4e6..901bdfe42c8 100644 --- a/python/cudf/cudf/core/dataframe.py +++ b/python/cudf/cudf/core/dataframe.py @@ -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. @@ -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 -------- @@ -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))