xinrong-databricks opened a new pull request, #36452:
URL: https://github.com/apache/spark/pull/36452

   ### What changes were proposed in this pull request?
   The PR is proposed to
   - Implement `numeric_only` of `GroupBy.mean`
   - Adjust `numeric_only` of `GroupBy.median`
   
   
   ### Why are the changes needed?
   Improve API compatibility with pandas.
   
   ### Does this PR introduce _any_ user-facing change?
   Yes. `numeric_only` parameter behaves the same as pandas 1.4's.
   Take `GroupBy.mean` as an example:
   ```py
   >>> psdf = ps.DataFrame({"A": [1, 2, 1, 2],"B": [3.1, 4.1, 4.1, 3.1],"C": 
["a", "b", "b", "a"],"D": [True, False, False, True]})
   >>> psdf
      A    B  C      D
   0  1  3.1  a   True
   1  2  4.1  b  False
   2  1  4.1  b  False
   3  2  3.1  a   True
   
   >>> psdf.groupby('A').mean(numeric_only=False)
   ...: FutureWarning: Dropping invalid columns in GroupBy.mean is deprecated. 
In a future version, a TypeError will be raised. Before calling .mean, select 
only columns which should be valid for the function.
     warnings.warn(
        B    D
   A          
   1  3.6  0.5
   2  3.6  0.5
   
   >>> psdf.groupby('A').mean(numeric_only=None)
   ...: FutureWarning: Dropping invalid columns in GroupBy.mean is deprecated. 
In a future version, a TypeError will be raised. Before calling .mean, select 
only columns which should be valid for the function.
     warnings.warn(
        B    D
   A          
   1  3.6  0.5
   2  3.6  0.5
   
   >>> psdf.groupby('A').mean(numeric_only=True)
        B    D
   A          
   1  3.6  0.5
   2  3.6  0.5
   ```
   
   ### How was this patch tested?
   Unit tests.
   


-- 
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-unsubscr...@spark.apache.org

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


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

Reply via email to