79075183

Date: 2024-10-10 15:45:29
Score: 1.5
Natty:
Report link

I find a simplest way to do that, but not sure whether it works or not.

result = df.orderBy(col("score").desc(), col("id1").asc(), col("id2").asc()).dropDuplicates(["id2", "score"]).drop("score").select('id1', 'id2').dropDuplicates(["id1"]).dropDuplicates(["id2"])
Reasons:
  • Low length (0.5):
  • Has code block (-0.5):
  • Self-answer (0.5):
  • Low reputation (1):
Posted by: Zhang Jovy