You are viewing a plain text version of this content. The canonical link for it is here.
Posted to reviews@spark.apache.org by GitBox <gi...@apache.org> on 2021/10/11 14:27:32 UTC

[GitHub] [spark] HyukjinKwon commented on a change in pull request #34240: [SPARK-36972][PYTHON]Add max_by/min_by API to PySpark

HyukjinKwon commented on a change in pull request #34240:
URL: https://github.com/apache/spark/pull/34240#discussion_r726168788



##########
File path: python/pyspark/sql/functions.py
##########
@@ -199,6 +199,76 @@ def min(col: "ColumnOrName") -> Column:
     return _invoke_function_over_column("min", col)
 
 
+@since(3.3)
+def max_by(col: "ColumnOrName", ord: "ColumnOrName") -> Column:
+    """
+    Returns the value associated with the maximum value of ord.
+
+    .. versionadded:: 3.3.0
+
+    Parameters
+    ----------
+    col : :class:`~pyspark.sql.Column` or str
+        target column that the value will be returned
+    ord : :class:`~pyspark.sql.Column` or str
+        column to be maximized
+
+    Returns
+    -------
+    :class:`~pyspark.sql.Column`
+        value associated with the maximum value of ord.
+
+    Examples
+    --------
+    >>> from pyspark.sql.functions import max_by
+    >>> spark.createDataFrame([
+    ...     ("Java", 2012, 20000), \\

Review comment:
       Actually you can remove \\ here




-- 
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.

To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



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