VOOZH about

URL: https://www.geeksforgeeks.org/python/drop-rows-containing-specific-value-in-pyspark-dataframe/

⇱ Drop rows containing specific value in PySpark dataframe - GeeksforGeeks


  • Courses
  • Tutorials
  • Interview Prep

Drop rows containing specific value in PySpark dataframe

Last Updated : 30 Jun, 2021

In this article, we are going to drop the rows with a specific value in pyspark dataframe.

Creating dataframe for demonstration:

Output:

👁 Image

Method 1: Using where() function

This function is used to check the condition and give the results. That means it drops the rows based on the values in the dataframe column

Syntax: dataframe.where(condition)

Example 1: Python program to drop rows with college = vrs.

Output:

👁 Image

Example 2: Python program to drop rows with ID=1

Output:

👁 Image

Method 2: Using filter() function

This function is used to check the condition and give the results, Which means it drops the rows based on the values in the dataframe column. Both are similar.

Syntax: dataframe.filter(condition)

Example: Python code to drop row with name = ravi.

Output:

👁 Image
Comment
Article Tags: