Skip to content

Conversation

@pravingadakh
Copy link
Contributor

What changes were proposed in this pull request?

Replacing "" (not null) with string "EMPTY_STRING" in StringIndexer. Another approach is to use "0" (or next available integer), but it may have performance issues when input column has integer values say (0 to 100000). We can use another string to replace "" values if "EMPTY_STRING" is commonly used.

How was this patch tested?

unit tests

@AmplabJenkins
Copy link

Can one of the admins verify this patch?


test("StringIndexer on column with empty string values") {
val data = sc.parallelize(Seq((0, "a"), (1, ""), (2, "c"), (3, "a"), (4, "a"), (5, "c")), 2)
val df = sqlContext.createDataFrame(data).toDF("id", "label")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These two lines could be written as:

Seq((0, "a"), (1, ""), (2, "c"), (3, "a"), (4, "a"), (5, "c")).toDF("id", "label")

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@jaceklaskowski Yes you are right. I'm using Intellij ide, which requires you add import sqlContext.implicits._ in order to use syntax mentioned by you. Thus I was avoiding that.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants