Github user davies commented on a diff in the pull request:
https://github.com/apache/spark/pull/10876#discussion_r51189727
--- Diff: python/pyspark/sql/functions.py ---
@@ -263,6 +263,38 @@ def corr(col1, col2):
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"])
+ >>> covDf = df.agg(covar_pop("a", "b").alias('c'))
+ >>> covDf.selectExpr('abs(c - 565.25) < 1e-16 as t').collect()
--- End diff --
Since these are going to be part of the API docs, I'd like to be as simple
as possible.
Also the Python API is only a wrapper of Scala one, so we don't need to
test the correctness here.
---
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 [email protected] or file a JIRA ticket
with INFRA.
---
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]