Skip to content

Commit

Permalink
basic mapper
Browse files Browse the repository at this point in the history
  • Loading branch information
pyspark-in-action committed Mar 12, 2015
1 parent e4499a7 commit a92461b
Showing 1 changed file with 26 additions and 0 deletions.
26 changes: 26 additions & 0 deletions basic-map/basic-map.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
# ./pyspark
Python 2.6.9 (unknown, Sep 9 2014, 15:05:12)
Welcome to
____ __
/ __/__ ___ _____/ /__
_\ \/ _ \/ _ `/ __/ '_/
/__ / .__/\_,_/_/ /_/\_\ version 1.2.0
/_/

Using Python version 2.6.9 (unknown, Sep 9 2014 15:05:12)
SparkContext available as sc.
>>> sc
<pyspark.context.SparkContext object at 0x10d926210>
>>>
>>> nums = sc.parallelize([1, 2, 3, 4, 5])
>>> nums.collect()
[1, 2, 3, 4, 5]
>>>
>>> bytwo = nums.map(lambda x: x + 2)
>>> bytwo.collect()
[3, 4, 5, 6, 7]
>>>
>>> squared = nums.map(lambda x: x * x)
>>> squared.collect()
[1, 4, 9, 16, 25]
>>>

0 comments on commit a92461b

Please sign in to comment.