Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
316 views
in Technique[技术] by (71.8m points)

apache spark - replace group by with reducebykey

I have the following code in dataframe. I am using the following statement to perform group by and it is not performing well on big datasets.

npa = npa.groupby(f.col('phonecode').alias('npa')).agg(f.mean('latitude').alias('latitude'), f.mean('longitude').alias('longitude'))

NPA dataset:-
+---------+---------+-----------+------------+
|phonecode| latitude|  longitude|country     |
+---------+---------+-----------+------------+
|   425   |47.496384|-121.784424|          US|
|   360   |47.540962|  -122.6358|          US|

Please advise how I can use reducebykey to solve the performance issue.

question from:https://stackoverflow.com/questions/65648960/replace-group-by-with-reducebykey

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)
Waitting for answers

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...