zhengruifeng opened a new pull request, #37845:
URL: https://github.com/apache/spark/pull/37845

   ### What changes were proposed in this pull request?
   refactor `pearson` correlation in `DataFrame.corr` to:
   1, support missing values;
   2, add parameter  `min_periods`;
   3, enable arrow execution since no longer depend on `VectorUDT`
   
   before
   ```
   In [1]: import pyspark.pandas as ps
   
   In [2]: df = ps.DataFrame([[1,2], [3,None]])
   
   In [3]: df
                                                                                
   
      0    1
   0  1  2.0
   1  3  NaN
   
   In [4]: df.corr()
   22/09/09 16:53:18 ERROR Executor: Exception in task 9.0 in stage 5.0 (TID 24)
   org.apache.spark.SparkException: [FAILED_EXECUTE_UDF] Failed to execute user 
defined function (VectorAssembler$$Lambda$2660/0x0000000801215840: 
(struct<0_double_VectorAssembler_0915f96ec689:double,1:double>) => 
struct<type:tinyint,size:int,indices:array<int>,values:array<double>>)
   ```
   
   after
   ```
   In [1]: import pyspark.pandas as ps
   
   In [2]: df = ps.DataFrame([[1,2], [3,None]])
   
   In [3]: df.corr()
                                                                                
   
        0   1
   0  1.0 NaN
   1  NaN NaN
   
   In [4]: df.to_pandas().corr()
   /Users/ruifeng.zheng/Dev/spark/python/pyspark/pandas/utils.py:976: 
PandasAPIOnSparkAdviceWarning: `to_pandas` loads all data into the driver's 
memory. It should only be used if the resulting pandas DataFrame is expected to 
be small.
     warnings.warn(message, PandasAPIOnSparkAdviceWarning)
   Out[4]: 
        0   1
   0  1.0 NaN
   1  NaN NaN
   ```
   
   
   ### Why are the changes needed?
   for API coverage and support common cases containing missing values
   
   
   ### Does this PR introduce _any_ user-facing change?
   new API
   
   
   ### How was this patch tested?
   added UT


-- 
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: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to