Notice: this is for Spark version 2.1.1.2.6.1.0-129
I have a spark dataframe (Python). I would like to replace all instances of 0 across the entirety of the dataframe (without specifying particular column names), with NULL values.
The following is the code that I have written:
my_df = my_df.na.replace(0, None)
The following is the error that I receive:
File "<stdin>", line 1, in <module>
File "/usr/hdp/current/spark2-client/python/pyspark/sql/dataframe.py", line 1634, in replace
return self.df.replace(to_replace, value, subset)
File "/usr/hdp/current/spark2-client/python/pyspark/sql/dataframe.py", line 1323, in replace
raise ValueError("value should be a float, int, long, string, list, or tuple")
ValueError: value should be a float, int, long, string, list, or tuple
my_df.na.replace(0, None)works fine for me (Spark 3.x) What's your Spark version?