-
Notifications
You must be signed in to change notification settings - Fork 371
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
c364faa
commit b61704d
Showing
1,132 changed files
with
197,378 additions
and
66,870 deletions.
There are no files selected for viewing
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
6 changes: 6 additions & 0 deletions
6
Chapter04/.ipynb_checkpoints/CHAPTER_4_Divide_and_conquer-checkpoint.ipynb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
{ | ||
"cells": [], | ||
"metadata": {}, | ||
"nbformat": 4, | ||
"nbformat_minor": 2 | ||
} |
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,139 @@ | ||
{ | ||
"cells": [ | ||
{ | ||
"cell_type": "code", | ||
"execution_count": null, | ||
"metadata": {}, | ||
"outputs": [], | ||
"source": [ | ||
"import findspark\n", | ||
"findspark.init()\n", | ||
"from pyspark.sql import SparkSession\n", | ||
"spark = SparkSession.builder.master(\"local[*]\").getOrCreate()\n", | ||
"sc = spark.sparkContext" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": 17, | ||
"metadata": {}, | ||
"outputs": [ | ||
{ | ||
"data": { | ||
"text/html": [ | ||
"\n", | ||
" <div>\n", | ||
" <p><b>SparkContext</b></p>\n", | ||
"\n", | ||
" <p><a href=\"http://07c60a334272:4040\">Spark UI</a></p>\n", | ||
"\n", | ||
" <dl>\n", | ||
" <dt>Version</dt>\n", | ||
" <dd><code>v2.4.4</code></dd>\n", | ||
" <dt>Master</dt>\n", | ||
" <dd><code>local[*]</code></dd>\n", | ||
" <dt>AppName</dt>\n", | ||
" <dd><code>pyspark-shell</code></dd>\n", | ||
" </dl>\n", | ||
" </div>\n", | ||
" " | ||
], | ||
"text/plain": [ | ||
"<SparkContext master=local[*] appName=pyspark-shell>" | ||
] | ||
}, | ||
"execution_count": 17, | ||
"metadata": {}, | ||
"output_type": "execute_result" | ||
} | ||
], | ||
"source": [ | ||
"sc" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": 18, | ||
"metadata": {}, | ||
"outputs": [ | ||
{ | ||
"name": "stdout", | ||
"output_type": "stream", | ||
"text": [ | ||
"['python', 'java', 'ottawa', 'ottawa', 'java', 'news']\n" | ||
] | ||
} | ||
], | ||
"source": [ | ||
"wordsList = ['python', 'java', 'ottawa', 'ottawa', 'java','news']\n", | ||
"wordsRDD = sc.parallelize(wordsList, 4)\n", | ||
"# Print out the type of wordsRDD\n", | ||
"print (wordsRDD.collect())" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": 19, | ||
"metadata": {}, | ||
"outputs": [ | ||
{ | ||
"name": "stdout", | ||
"output_type": "stream", | ||
"text": [ | ||
"[('python', 1), ('java', 1), ('ottawa', 1), ('ottawa', 1), ('java', 1), ('news', 1)]\n" | ||
] | ||
} | ||
], | ||
"source": [ | ||
"wordPairs = wordsRDD.map(lambda w: (w, 1))\n", | ||
"print (wordPairs.collect())" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": 20, | ||
"metadata": {}, | ||
"outputs": [ | ||
{ | ||
"name": "stdout", | ||
"output_type": "stream", | ||
"text": [ | ||
"[('python', 1), ('java', 2), ('ottawa', 2), ('news', 1)]\n" | ||
] | ||
} | ||
], | ||
"source": [ | ||
"wordCountsCollected = wordPairs.reduceByKey(lambda x,y: x+y)\n", | ||
"print(wordCountsCollected.collect())" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": null, | ||
"metadata": {}, | ||
"outputs": [], | ||
"source": [] | ||
} | ||
], | ||
"metadata": { | ||
"kernelspec": { | ||
"display_name": "Python 3", | ||
"language": "python", | ||
"name": "python3" | ||
}, | ||
"language_info": { | ||
"codemirror_mode": { | ||
"name": "ipython", | ||
"version": 3 | ||
}, | ||
"file_extension": ".py", | ||
"mimetype": "text/x-python", | ||
"name": "python", | ||
"nbconvert_exporter": "python", | ||
"pygments_lexer": "ipython3", | ||
"version": "3.7.3" | ||
} | ||
}, | ||
"nbformat": 4, | ||
"nbformat_minor": 2 | ||
} |
Oops, something went wrong.