我的数据如下所示:
   id | duration | action1 | action2 | ...
 ---------------------------------------------
    1 | 10       |   A     |   D
    1 | 10       |   B     |   E 
    2 | 25       |   A     |   E
    1 | 7        |   A     |   G
Run Code Online (Sandbox Code Playgroud)
我想按 ID 对其进行分组(效果很好!):
df.rdd.groupBy(lambda x: x['id']).mapValues(list).collect()
Run Code Online (Sandbox Code Playgroud)
现在我想按持续时间对每个组内的值进行分组以获得如下所示的内容:
    [(id=1,
      ((duration=10,[(action1=A,action2=D),(action1=B,action2=E),
       (duration=7,(action1=A,action2=G)),
     (id=2,
       ((duration=25,(action1=A,action2=E)))]
Run Code Online (Sandbox Code Playgroud)
这是我不知道如何进行嵌套组的地方。有小费吗?