Один из вариантов:
//Create dataframe
val df = sc.parallelize(
Seq(("AAA", 0.0, 12.0,12.0,0.0, 0.0, 0.0, 10.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0),
("AAB", 12.0, 12.0, 12.0, 10.0, 12.0, 12.0, 12.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0),
("AAC", 10.0, 12.0, 0.0, 0.0, 0.0, 10.0, 10.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0),
("ZZZ", 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 110.0,0.0, 0.0, 0.0, 0.0, 0.0, 0.0)
)).toDF("subaccid","srp0","srp1","srp2","srp3","srp4","srp5","srp6","srp7","srp8","srp9","srp10","srp11","srp12")
val df2 = df.rdd.map(x => (x.getString(0), x.toSeq.tail.filter(_ != 0).length)).toDF("subaccid", "count")
df2.show
//output
+--------+-----+
|subaccid|count|
+--------+-----+
| AAA| 3|
| AAB| 7|
| AAC| 4|
| ZZZ| 1|
+--------+-----+
Конечно, это включает в себя преобразование в rdd и обратно.