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 2022/04/14 05:00:04 UTC
[GitHub] [spark] itholic commented on a diff in pull request #36148: [SPARK-38880][PYTHON] Implement `numeric_only` parameter of `GroupBy.max/min`
itholic commented on code in PR #36148:
URL: https://github.com/apache/spark/pull/36148#discussion_r850082074
##########
python/pyspark/pandas/groupby.py:
##########
@@ -426,16 +427,45 @@ def last(self) -> FrameLike:
lambda col: F.last(col, ignorenulls=True), only_numeric=False
)
- def max(self) -> FrameLike:
+ def max(self, numeric_only: Optional[bool] = False) -> FrameLike:
"""
Compute max of group values.
+ Parameters
+ ----------
+ numeric_only : bool, default False
+ Include only float, int, boolean columns. If None, will attempt to use
+ everything, then use only numeric data.
+
+ .. versionadded:: 3.4.0
+
See Also
--------
pyspark.pandas.Series.groupby
pyspark.pandas.DataFrame.groupby
+
+ Examples
+ --------
+ >>> df = ps.DataFrame({"A": [1, 2, 1, 2], "B": [True, False, False, True],
+ ... "C": [3, 4, 3, 4], "D": ["a", "b", "b", "a"]})
+
+ >>> df.groupby("A").max().sort_index()
+ B C D
+ A
+ 1 True 3 b
+ 2 True 4 b
Review Comment:
Thanks for also adding the normal case testing!
--
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