I have a spark dataframe:

```
+-----------+--------------------+
|columnIndex|               lists|
+-----------+--------------------+
|          1|[1.0,2.0]           |
|          2|[2.0]               |
|          3|[1.0]               |
|          4|[1.0,3.0]           |
+-----------+--------------------+

```

I need to get the following after one-hot encoding or get\_dummies:

```
+-----------+--------------------+---+---+---+
|columnIndex|               lists|1.0|2.0|3.0|
+-----------+--------------------+---+---+---+
|          1|[1.0,2.0]           |  1|  1|  0|
|          2|[2.0]               |  0|  1|  0|
|          3|[1.0]               |  1|  0|  0|
|          4|[1.0,3.0]           |  1|  0|  1|
+-----------+--------------------+---+---+---+

```

I have tried CountVectorizer(), but could not get the needed output. This example is a sample for the data that I have.