I am trying to group some data by key where the value would be a list:
Sample data:
A 1 A 2 B 1 B 2
Expected result:
(A
You're almost there. Just replace List(_) with _.toList
List(_)
_.toList
data.groupByKey.mapValues(_.toList)