Namitha Janardhanan
Namitha Janardhanan

Reputation: 23

Removing Null records in pyspark

I have a spark dataframe like below

Id value
1   \N
2   \N
3    a
4    b
5   \N

I want to remove the \N records, which are null, from the df. How to do this?

Upvotes: 0

Views: 57

Answers (1)

samkart
samkart

Reputation: 6644

the simple filter should work.

data_sdf.filter(data_sdf.value != r'\N').show()

# +---+-----+
# | id|value|
# +---+-----+
# |  3|    a|
# |  4|    b|
# +---+-----+

Upvotes: 1

Related Questions