I have a dataset which is the output of a pipe in scalding that looks like this:
'Var1, 'Var2, 'Var3, 'Var4 =
a,x,1,2
a,y,3,4
b,x,1,2
b,y,3,4
I'm trying to turn it into something like:
'Var1, 'Var3x, 'Var4x, 'Var3y, 'Var4y =
a,1,2,3,4
b,1,2,3,4
First I thought using flatMap somehow would work but that didn't seem right. Seems like some use of pivot function should work, but I can't quite work out how to pivot multiple columns.
Any help is appreciated.
You need to combine your two value columns into one, and then you can use .pivot. Something like this: