How do I do a summation of the frequency based on distinct ID & Location in PySpark?
Feels like I need to do window partition by ID and Location and then add the frequency but not sure how to write this in Pyspark code:
Input
Just a simple group by and sum:
import pyspark.sql.functions as F df2 = df.groupBy('ID', 'Location').agg(F.sum('Frequency').alias('TotalFrequency'))
1.4m articles
1.4m replys
5 comments
57.0k users