Spark 2.2 onwards
df.filter(df.location.contains('google.com'))Spark 2.2 documentation link
Spark 2.1 and before
Answer from mrsrinivas on Stack OverflowYou can use plain SQL in
filterdf.filter("location like '%google.com%'")or with DataFrame column methods
df.filter(df.location.like('%google.com%'))Spark 2.1 documentation link
Spark By {Examples}
sparkbyexamples.com › home › pyspark › pyspark filter using contains() examples
PySpark Filter using contains() Examples - Spark By {Examples}
May 6, 2026 - PySpark SQL contains() function is used to match a column value contains in a literal string (matches on part of the string), this is mostly used to
Top answer 1 of 4
159
Spark 2.2 onwards
df.filter(df.location.contains('google.com'))Spark 2.2 documentation link
Spark 2.1 and before
You can use plain SQL in
filterdf.filter("location like '%google.com%'")or with DataFrame column methods
df.filter(df.location.like('%google.com%'))Spark 2.1 documentation link
2 of 4
23
pyspark.sql.Column.contains() is only available in pyspark version 2.2 and above.
df.where(df.location.contains('google.com'))
Apache
spark.apache.org › docs › latest › api › python › reference › pyspark.sql › api › pyspark.sql.Column.contains.html
pyspark.sql.Column.contains — PySpark 4.1.2 documentation
Contains the other element. Returns a boolean Column based on a string match. Changed in version 3.4.0: Supports Spark Connect. Parameters · other · string in line. A value as a literal or a Column. Examples · >>> df = spark.createDataFrame( ... [(2, "Alice"), (5, "Bob")], ["age", "name"]) ...
Statology
statology.org › home › pyspark: filter for rows that contain one of multiple values
PySpark: Filter for Rows that Contain One of Multiple Values
October 12, 2023 - We can use the following syntax to filter the DataFrame to only contain rows where the team column contains “ets” or “urs” somewhere in the string:
Application-architect
application-architect.com › home › python › pyspark - filter rows using contains()
PySpark - Filter Rows Using contains() | Application Architect
October 16, 2025 - The contains() method is your go-to tool for substring filtering in PySpark.
Sqlandhadoop
sqlandhadoop.com › pyspark-filter-25-examples-to-teach-you-everything
PySpark Filter – 25 examples to teach you everything – SQL & Hadoop
PySpark contains filter condition is similar to LIKE where you check if the column value contains any give value in it or not. Basically you check if the sub-string exists in the string or not.
MungingData
mungingdata.com › pyspark › filter-array
Filtering PySpark Arrays and DataFrame Array Columns - MungingData
The pyspark.sql.DataFrame#filter method and the pyspark.sql.functions#filter function share the same name, but have different functionality. One removes elements from an array and the other removes rows from a DataFrame. It's important to understand both. The rest of this post provides clear examples. Suppose you have the following DataFrame with a some_arr column that contains numbers.
Spark Code Hub
sparkcodehub.com › pyspark › dataframe › filter-rows-array-contains
How to Filter Rows with array_contains in an Array Column in a PySpark DataFrame: The Ultimate Guide
array_contains() function checks if a specified value is present in an array column, returning a boolean that can be used with · filter() to select matching rows. This is ideal for scenarios where you need to query complex data, like lists of skills, tags, or product IDs, without unpacking ...
Dbmstutorials
dbmstutorials.com › pyspark › spark-dataframe-filters.html
PySpark: Dataframe Filters
This tutorial will explain how filters can be used on dataframes in Pyspark. where() function is an alias for filter() function. Following topics will be covered on this page: Basic filters · Filter using IN clause · Filter using not IN clause · Filter using List · Filter Null Values · Filter not Null Values · Filter using LIKE operator · Filter using not LIKE operator · Filter using Contains ·
Skytowner
skytowner.com › explore › pyspark_column_contains_method
PySpark Column | contains method with Examples
PySpark Column's contains(~) method returns a Column object of booleans where True corresponds to column values that contain the specified substring.