'Generate sparse vector for all the column values in spark dataframe

column1 column2
1 1
1 0
1 0
0 0

Now I want to calculate the hash or sparse vector of all the values in column1 and column2



Solution 1:[1]

You can use VectorAssembler. It creates SparseVector by default.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 pltc