Spark dataframe: Pivot and Group based on columns

前端 未结 2 1377
执笔经年
执笔经年 2021-01-19 15:10

I have input dataframe as below with id, app, and customer

Input dataframe

+--------------------+-----+---------+
|                          


        
2条回答
  •  孤街浪徒
    2021-01-19 15:22

    Using CONCAT_WS we can explode array and can remove the square brackets.

    df.groupBy("id").pivot("app").agg(concat_ws(",",collect_list("customer")))
    

提交回复
热议问题