I am using spark with scala.
Imagine the input:
I would like to know how to get the following output [see the column accumulator on the following image] which should be a Array of type String Array[String]
In my real dataframe I have more than 3 columns. I have several thousand of column.
How can I proceed in order to get my desired output?
You can use an
array
function and map a sequence of columns:where
takes a column name if column value is different than zero and null otherwise.
and use an UDF to filter nulls:
So with example data:
you first get:
and finally: