Github user davies commented on a diff in the pull request:

    https://github.com/apache/spark/pull/10876#discussion_r52645800
  
    --- Diff: python/pyspark/sql/functions.py ---
    @@ -254,15 +254,44 @@ def corr(col1, col2):
     
         >>> a = [x * x - 2 * x + 3.5 for x in range(20)]
         >>> b = range(20)
    -    >>> corrDf = sqlContext.createDataFrame(zip(a, b))
    -    >>> corrDf = corrDf.agg(corr(corrDf._1, corrDf._2).alias('c'))
    -    >>> corrDf.selectExpr('abs(c - 0.9572339139475857) < 1e-16 as 
t').collect()
    -    [Row(t=True)]
    +    >>> df = sqlContext.createDataFrame(zip(a, b))
    +    >>> df.agg(corr(df._1, df._2))
    +    DataFrame[corr(_1,_2): double]
         """
         sc = SparkContext._active_spark_context
         return Column(sc._jvm.functions.corr(_to_java_column(col1), 
_to_java_column(col2)))
     
     
    +@since(2.0)
    +def covar_pop(col1, col2):
    +    """Returns a new :class:`Column` for the population covariance of 
``col1``
    +    and ``col2``.
    +
    +    >>> a = [x * x - 2 * x + 3.5 for x in range(20)]
    +    >>> b = range(20)
    +    >>> df = sqlContext.createDataFrame(zip(a, b), ["a", "b"])
    +    >>> df.agg(covar_pop("a", "b"))
    +    DataFrame[covar_pop(a,b): double]
    +    """
    +    sc = SparkContext._active_spark_context
    +    return Column(sc._jvm.functions.covar_pop(_to_java_column(col1), 
_to_java_column(col2)))
    +
    +
    +@since(2.0)
    +def covar_samp(col1, col2):
    +    """Returns a new :class:`Column` for the sample covariance of ``col1``
    +    and ``col2``.
    +
    +    >>> a = [x * x - 2 * x + 3.5 for x in range(20)]
    +    >>> b = range(20)
    +    >>> df = sqlContext.createDataFrame(zip(a, b), ["a", "b"])
    --- End diff --
    
    How about a == b, then the result will be zero?


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---

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

Reply via email to