Github user holdenk commented on a diff in the pull request:
https://github.com/apache/spark/pull/10876#discussion_r50753821
--- 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.select("c").collect()
+ [Row(c=565.25)]
--- End diff --
Should we maybe compare with a tolerance as done in the other doctests
since floating point?
---
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]