Skip to content
Snippets Groups Projects
Commit 20adf9aa authored by John O'Leary's avatar John O'Leary Committed by hyukjinkwon
Browse files

[SPARK-22107] Change as to alias in python quickstart

## What changes were proposed in this pull request?

Updated docs so that a line of python in the quick start guide executes. Closes #19283

## How was this patch tested?

Existing tests.

Author: John O'Leary <jgoleary@gmail.com>

Closes #19326 from jgoleary/issues/22107.
parent 576c43fb
No related branches found
No related tags found
No related merge requests found
...@@ -153,7 +153,7 @@ This first maps a line to an integer value and aliases it as "numWords", creatin ...@@ -153,7 +153,7 @@ This first maps a line to an integer value and aliases it as "numWords", creatin
One common data flow pattern is MapReduce, as popularized by Hadoop. Spark can implement MapReduce flows easily: One common data flow pattern is MapReduce, as popularized by Hadoop. Spark can implement MapReduce flows easily:
{% highlight python %} {% highlight python %}
>>> wordCounts = textFile.select(explode(split(textFile.value, "\s+")).as("word")).groupBy("word").count() >>> wordCounts = textFile.select(explode(split(textFile.value, "\s+")).alias("word")).groupBy("word").count()
{% endhighlight %} {% endhighlight %}
Here, we use the `explode` function in `select`, to transfrom a Dataset of lines to a Dataset of words, and then combine `groupBy` and `count` to compute the per-word counts in the file as a DataFrame of 2 columns: "word" and "count". To collect the word counts in our shell, we can call `collect`: Here, we use the `explode` function in `select`, to transfrom a Dataset of lines to a Dataset of words, and then combine `groupBy` and `count` to compute the per-word counts in the file as a DataFrame of 2 columns: "word" and "count". To collect the word counts in our shell, we can call `collect`:
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment