PySpark: How to fillna values in dataframe for specific columns?

Solution 1:

df.fillna(0, subset=['a', 'b'])

There is a parameter named subset to choose the columns unless your spark version is lower than 1.3.1

Solution 2:

Use a dictionary to fill values of certain columns:

df.fillna( { 'a':0, 'b':0 } )