+-----------+----------+-----+
| M | Index|c1 |
+-----------+----------+-----+
|M1 | 0| 224|
|M1 | 1| 748|
|M1 | 3| 56|
+-----------+----------+-----+
I have a DF like above. If I use pivot -
df.groupBy("M").pivot("Index").agg(first("c1"))
, I ll get something like below.But this means I am missing '2' in the series. But,this may be silly but tricky, Is there any way to fill up the column series while doing pivot
+-----------+----+---+---+
| M | 0| 1| 3|
+-----------+----+---+---+
|M1 |224 |748| 56|
+-----------+----+---+---+
Expect Result
+-----------+----+---+---+--+
| M | 0| 1| 2|3 |
+-----------+----+---+---+---
|M1 |224 |748| 0 |56|
+-----------+----+---+---+--+