Answers for "pyspark dataframe fill null with 0"

0

pyspark dataframe fill null with 0

>>> df = spark.createDataFrame([(1,), (2,), (3,), (None,)], ['col'])
>>> df.show()
+----+
| col|
+----+
|   1|
|   2|
|   3|
|null|
+----+

>>> df.na.fill(0).show()
+---+
|col|
+---+
|  1|
|  2|
|  3|
|  0|
+---+
Posted by: Guest on April-24-2021

Browse Popular Code Answers by Language