Skip to content

Commit

Permalink
Update the summation of reduce(lambda x, y: x + y)
Browse files Browse the repository at this point in the history
The output is 0, instead of 6. It looks like the list of elements is 1+2+(-3) = 0
  • Loading branch information
philipai authored Oct 12, 2024
1 parent 8c843e6 commit 1c135ba
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion Notebooks/Spark-Example-02-RDD Basics Toutorial.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -1539,7 +1539,7 @@
],
"source": [
"# reduce\n",
"x = sc.parallelize([1,2,3])\n",
"x = sc.parallelize([1,2,-3])\n",
"y = x.reduce(lambda x, y: x + y) # computes a cumulative sum\n",
"print(\"x=\",x.collect())\n",
"print(y)"
Expand Down

0 comments on commit 1c135ba

Please sign in to comment.