Github user viirya commented on a diff in the pull request: https://github.com/apache/spark/pull/18732#discussion_r142561534 --- Diff: python/pyspark/sql/group.py --- @@ -194,6 +194,65 @@ def pivot(self, pivot_col, values=None): jgd = self._jgd.pivot(pivot_col, values) return GroupedData(jgd, self.sql_ctx) + def apply(self, udf): + """ + Maps each group of the current :class:`DataFrame` using a pandas udf and returns the result + as a :class:`DataFrame`. + + The user-function should take a `pandas.DataFrame` and return another `pandas.DataFrame`. + Each group is passed 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 arbitrary length and its schema should match the returnType of the pandas udf. --- End diff -- Can the returned `pandas.DataFrame` be arbitrary length? Since we apply it on a `GroupedData`, I think this `apply` should work like aggregation as `count`, `avg` and returned `pandas.DataFrame` should be 1 length?
--- --------------------------------------------------------------------- To unsubscribe, e-mail: reviews-unsubscr...@spark.apache.org For additional commands, e-mail: reviews-h...@spark.apache.org