Apache Spark Dataframe Groupby agg() for multiple columns

前端 未结 1 1774
逝去的感伤
逝去的感伤 2020-12-30 06:04

I have a DataFrame with 3 columns i.e. Id, First Name, Last Name

I want to apply GroupBy on the basis of Id and w

相关标签:
1条回答
  • 2020-12-30 06:28

    You can aggregate multiple columns like this:

    df.groupBy("id").agg(collect_list("fName"), collect_list("lName"))
    

    It will give you the expected result.

    0 讨论(0)
提交回复
热议问题