from pyspark.sql import Row
row = Row('x', 'y', 'z')
df = sc.parallelize([row(0, 1, 2), row(None, 3, 4), row(None, None, 5)]).toDF()
Count number of non-NaN entries in each column of Spark dataframe with Pyspark