I have a df like this:
+----------+----------+----------+----------+----------+----------+----------+
| user_id| apple| orange| banana| pear| table| desk|
+----------+----------+----------+----------+----------+----------+----------+
| 1| 13| null| 55| null| null| null|
| 2| 30| null| null| null| null| null|
| 3| null| null| 50| null| null| null|
| 4| 1| null| 3| null| null| null|
+----------+----------+----------+----------+----------+----------+----------+
I would like to get back an Array[String] which contains the fruit column names which are have only null values. I would like to do this on a very big data frame so i don't want to sum the columns, i need a faster and much more efficient way. I need a Scala code.
So i need this list:
List(orange,pear)
I have this solution now, summing columns, but i need a solution without summing all of the columns:
val fruitList: Array[String] = here are the fruit names
val nullFruits: Array[String] = fruitList.filter(col => dataFrame.agg(sum(col)).first.get(0) == null)