How to transform the DataFrame from
l x y z
0 a 1 0 0
1 a 0 1 0
2 a 0 0 1
3 b 1 0 0
4 b 0 0 1
to
l x y z
0 a 1 1 1
1 b 1 0 1
for each unique value in column l
, compress the other column's value into 0 or 1.
values for x, y, z
is either 1 or 0.
The original DataFrame has the property: for each unique of l
, x, y
or z
only has one 1
at most.