-
Notifications
You must be signed in to change notification settings - Fork 28.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[SPARK-12962] [SQL] [PySpark] PySpark support covar_samp and covar_pop #10876
Conversation
Test build #49909 has finished for PR 10876 at commit
|
>>> 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)] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should we maybe compare with a tolerance as done in the other doctests since floating point?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Test build #50164 has finished for PR 10876 at commit
|
This looks good to me, maybe @davies or @jkbradley could take a look? |
>>> 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() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So just as a side note - it seems the other functions (including corr) do have these tests for correctness in their doctests. We should probably be consistent with them one way or the other yes?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, we should cleanup them up.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@davies OK, I will cleanup them.
@yanboliang Could you also add Python API for corr? |
@felixcheung I see, thanks! |
Test build #50344 has finished for PR 10876 at commit
|
ping @davies |
@yanboliang I'm sorry that I didn't make it clear: It's good to have a simple test, that could also be used as an example to demo how to use these functions (it should be as simple as possible). |
ad15ff4
to
8029911
Compare
Test build #51104 has finished for PR 10876 at commit
|
Test build #51106 has finished for PR 10876 at commit
|
|
||
>>> a = [x * x - 2 * x + 3.5 for x in range(20)] | ||
>>> b = range(20) | ||
>>> df = sqlContext.createDataFrame(zip(a, b), ["a", "b"]) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How about a == b, then the result will be zero?
Test build #51181 has finished for PR 10876 at commit
|
Test build #51183 has finished for PR 10876 at commit
|
LGTM, merging into master, thanks! |
PySpark support
covar_samp
andcovar_pop
.cc @rxin @davies @marmbrus