Guest User

Untitled

a guest
Oct 17th, 2017
86
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.50 KB | None | 0 0
  1. ratings = spark.createDataFrame(
  2. sc.textFile("myfile.json").map(lambda l: json.loads(l)),
  3. )
  4.  
  5.  
  6.  
  7. ratings.registerTempTable("mytable")
  8.  
  9. final_df = sqlContext.sql("select * from mytable");
  10.  
  11. user_id_list = final_df.select('user_id').rdd.flatMap(lambda x: x).collect()
  12. created_at_list = final_df.select('created_at').rdd.flatMap(lambda x: x).collect()
  13.  
  14. for i in range(len(user_id_list)):
  15. status=get_status(user_id_list[I],created_at_list[I])
  16.  
  17. final_df.withColumn('status', 'give the condition here')
Add Comment
Please, Sign In to add comment