viirya commented on a change in pull request #27109: [SPARK-30434][PYTHON][SQL] 
Move pandas related functionalities into 'pandas' sub-package
URL: https://github.com/apache/spark/pull/27109#discussion_r364036739
 
 

 ##########
 File path: python/pyspark/sql/pandas/group_ops.py
 ##########
 @@ -22,7 +22,83 @@
 from pyspark.sql.dataframe import DataFrame
 
 
-class CoGroupedData(object):
+class PandasGroupedOpsMixin(object):
+    """
+    Min-in for pandas grouped operations. Currently, only :class:`GroupedData`
+    can use this class.
+    """
+
+    def apply(self, udf):
+        """
+        Maps each group of the current :class:`DataFrame` using a pandas udf 
and returns the result
+        as a `DataFrame`.
+
+        The user-defined function should take a `pandas.DataFrame` and return 
another
+        `pandas.DataFrame`. For each group, all columns are passed together as 
a `pandas.DataFrame`
+        to the user-function and the returned `pandas.DataFrame` are combined 
as a
+        :class:`DataFrame`.
+
+        The returned `pandas.DataFrame` can be of arbitrary length and its 
schema must match the
+        returnType of the pandas udf.
+
+        .. note:: This function requires a full shuffle. All the data of a 
group will be loaded
+            into memory, so the user should be aware of the potential OOM risk 
if data is skewed
+            and certain groups are too large to fit in memory.
+
+        :param udf: a grouped map user-defined function returned by
+            :func:`pyspark.sql.functions.pandas_udf`.
+
+        >>> from pyspark.sql.functions import pandas_udf, PandasUDFType
 
 Review comment:
   ditto.

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


With regards,
Apache Git Services

---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscr...@spark.apache.org
For additional commands, e-mail: reviews-h...@spark.apache.org

Reply via email to