Guest User

Untitled

a guest
Nov 17th, 2017
79
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.40 KB | None | 0 0
  1. sc.textFile("/home/bibi/Desktop/distributed.csv") \
  2. .map(lambda line: line.split(",")) \
  3. .map(lambda line: (int(line[0]),float(line[2]))) \
  4. .combineByKey( lambda value: (value, 1),
  5. lambda x, value: (x[0] + value, x[1] + 1),
  6. lambda x, y: (x[0] + y[0], x[1] + y[1])) \
  7. .map(lambda (label, (value_sum, count)): (label, value_sum / count)) \
  8. .collectAsMap()
Add Comment
Please, Sign In to add comment