Uh oh!
There was an error while loading. Please reload this page.
[SPARK-14932][SQL] Allow DataFrame.replace() to replace values with None - #16225
[SPARK-14932][SQL] Allow DataFrame.replace() to replace values with None#16225jiayue-zhang wants to merge 8 commits into
Conversation
HyukjinKwon
commented
Dec 9, 2016
Would we need a test for Scala too? I checked this by myself and it seems working fine with Scala though. I could argue that this affects the language-specific functions of both Python and Scala as a not strong opinion. |
| case _ => replacement.map { case (k, v) => (convertToDouble(k), convertToDouble(v)) } | ||
| } | ||
| val replacementMap: Map[_, _] = | ||
| if (replacement.head._2 == null) |
There was a problem hiding this comment.
I think you can just write case null => here and thereby avoid the ifelse
There was a problem hiding this comment.
I tried that but failed. Scala doesn't allow pattern matching with null, scala.Nothing and scala.Null
There was a problem hiding this comment.
Oh, wait case null => works. I tried case v null which doesn't. Let me modify this. Thanks!
SparkQA
commented
Dec 10, 2016
Test build #3490 has finished for PR 16225 at commit
|
gatorsmile
commented
May 23, 2017
ok to test |
gatorsmile
commented
May 23, 2017
@bravo-zhang Could you resolve the conflicts? I will review it then. Thanks! |
SparkQA
commented
May 23, 2017
Test build #77261 has finished for PR 16225 at commit
|
jiayue-zhang
commented
May 24, 2017
Thanks for taking a look, @gatorsmile The conflicts have been resolved. |
SparkQA
commented
May 24, 2017
Test build #77273 has finished for PR 16225 at commit
|
SparkQA
commented
May 24, 2017
Test build #77282 has finished for PR 16225 at commit
|
holdenk
left a comment
There was a problem hiding this comment.
Thanks for working on this, sorry its taken so long to review. I did a first read through the Python side and I've got two minor questions. Hopefully @zero323, @davie , or @gatorsmile can also have some time once the current release is finished to take a look.
| "Got {0}".format(type(to_replace))) | ||
| if not isinstance(value, valid_types) and not isinstance(to_replace, dict): | ||
| if not isinstance(value, valid_types) and value is not None \ |
There was a problem hiding this comment.
So slightly jet lagged style question: would this be clearer if we just add type(None) to L1398? I know PEP8 says we should only use isis not for checking if something is none rather than depending on the implicit conversion to boolean -- but since really checking the type here we aren't really in danger of that. (This is just a suggestion to make it easier to read - if others think its easier to read this way thats fine :)). @davies ?
| to_replace = [to_replace] | ||
| if isinstance(value, (float, int, long, basestring)): | ||
| if isinstance(value, (float, int, long, basestring)) or value is None: |
| if not any(all_of_type(rep_dict.keys()) and all_of_type(rep_dict.values()) | ||
| if not any(all_of_type(rep_dict.keys()) | ||
| and (all_of_type(rep_dict.values()) | ||
| or list(rep_dict.values()).count(None) == len(rep_dict)) |
There was a problem hiding this comment.
In the Scala code null is allowed in to be the replacement value for some of the elements but not in the Python code. Is this intentional? If so we should document it clearly and expand on the error message bellow (otherwise we should make it more flexible).
gatorsmile
commented
Jun 27, 2017
We are closing it due to inactivity. please do reopen if you want to push it forward. Thanks! |
jiayue-zhang
commented
Aug 2, 2017
@holdenk Thanks for review. I'll combine type(None) in the |
## What changes were proposed in this pull request? This PR proposes to close stale PRs, mostly the same instances with apache#18017 I believe the author in apache#14807 removed his account. Closesapache#7075Closesapache#8927Closesapache#9202Closesapache#9366Closesapache#10861Closesapache#11420Closesapache#12356Closesapache#13028Closesapache#13506Closesapache#14191Closesapache#14198Closesapache#14330Closesapache#14807Closesapache#15839Closesapache#16225Closesapache#16685Closesapache#16692Closesapache#16995Closesapache#17181Closesapache#17211Closesapache#17235Closesapache#17237Closesapache#17248Closesapache#17341Closesapache#17708Closesapache#17716Closesapache#17721Closesapache#17937 Added: Closesapache#14739Closesapache#17139Closesapache#17445Closesapache#18042Closesapache#18359 Added: Closesapache#16450Closesapache#16525Closesapache#17738 Added: Closesapache#16458Closesapache#16508Closesapache#17714 Added: Closesapache#17830Closesapache#14742 ## How was this patch tested? N/A Author: hyukjinkwon <gurwls223@gmail.com> Closesapache#18417 from HyukjinKwon/close-stale-pr.
What changes were proposed in this pull request?
Allow DataFrame.replace() to replace with None/null values.
How was this patch tested?
Python doctest and unit test. Scala unit test.