pyspark dataframe filter code example
Example 1: pyspark filter
>>> df.filter(df.age > 3).collect()
[Row(age=5, name='Bob')]
>>> df.where(df.age == 2).collect()
[Row(age=2, name='Alice')]
Example 2: filter in pyspark
df.filter(df.state == "OH")
>>> df.filter(df.age > 3).collect()
[Row(age=5, name='Bob')]
>>> df.where(df.age == 2).collect()
[Row(age=2, name='Alice')]
df.filter(df.state == "OH")