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

前端 未结 2 1260
北荒
北荒 2020-12-01 09:59

I have the following sample DataFrame:

a    | b    | c   | 

1    | 2    | 4   |
0    | null | null| 
null | 3    | 4   |

And I want to rep

相关标签:
2条回答
  • 2020-12-01 10:43

    Use a dictionary to fill values of certain columns:

    df.fillna( { 'a':0, 'b':0 } )
    
    0 讨论(0)
  • 2020-12-01 11:03
    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

    0 讨论(0)
提交回复
热议问题