1# Replace null values
2
3df4.na.fill(50).show()
4# +---+------+-----+
5# |age|height| name|
6# +---+------+-----+
7# | 10| 80|Alice|
8# | 5| 50| Bob|
9# | 50| 50| Tom|
10# | 50| 50| null|
11# +---+------+-----+
12
13df5.na.fill(False).show()
14# +----+-------+-----+
15# | age| name| spy|
16# +----+-------+-----+
17# | 10| Alice|false|
18# | 5| Bob|false|
19# |null|Mallory| true|
20# +----+-------+-----+
21
22df4.na.fill({'age': 50, 'name': 'unknown'}).show()
23# +---+------+-------+
24# |age|height| name|
25# +---+------+-------+
26# | 10| 80| Alice|
27# | 5| null| Bob|
28# | 50| null| Tom|
29# | 50| null|unknown|
30# +---+------+-------+