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
Apache
spark.apache.org › docs › latest › api › python › reference › pyspark.sql › api › pyspark.sql.functions.contains.html
pyspark.sql.functions.contains — PySpark 4.2.0 documentation
pyspark.sql.functions.contains(left, right)[source]# Returns a boolean. The value is True if right is found inside left. Returns NULL if either input expression is NULL. Otherwise, returns False. Both left or right must be of STRING or BINARY type. New in version 3.5.0.
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
>>> df = spark.createDataFrame( ... [(2, "Alice"), (5, "Bob")], ["age", "name"]) >>> df.filter(df.name.contains('o')).collect() [Row(age=5, name='Bob')]
11:25
String Search in PySpark | contains, startswith, endswith, like, ...
05:38
PySpark String Functions Explained | contains(), startswith ...
11:01
PySpark Tutorial 24: Contains, Describe, Cast, Head | PySpark with ...
10. contains() in PySpark Explained
00:59
PySpark array contains function - 004 #pyspark - YouTube
Databricks
api-docs.databricks.com › python › pyspark › latest › pyspark.sql › api › pyspark.sql.Column.contains.html
pyspark.sql.Column.contains — PySpark master documentation
Contains the other element. Returns a boolean Column based on a string match · string in line. A value as a literal or a Column
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.functions.array_contains.html
pyspark.sql.functions.array_contains — PySpark 4.2.0 documentation
Example 1: Basic usage of array_contains function. >>> from pyspark.sql import functions as sf >>> df = spark.createDataFrame([(["a", "b", "c"],), ([],)], ['data']) >>> df.select(sf.array_contains(df.data, "a")).show() +-----------------------+ |array_contains(data, a)| +-----------------------+ | true| | false| +-----------------------+ Example 2: Usage of array_contains function with a column.
Apache
spark.apache.org › docs › latest › api › python › reference › pyspark.pandas › api › pyspark.pandas.Series.str.contains.html
pyspark.pandas.Series.str.contains — PySpark 4.2.0 documentation
A Series of boolean values indicating whether the given pattern is contained within the string of each element of the Series.
Statology
statology.org › home › pyspark: how to filter using “contains”
PySpark: How to Filter Using "Contains"
October 12, 2023 - #filter DataFrame where team column contains 'avs' df.filter(df.team.contains('avs')).show() The following example shows how to use this syntax in practice. Suppose we have the following PySpark DataFrame that contains information about points scored by various basketball players:
Statology
statology.org › home › pyspark: how to use case-insensitive “contains”
PySpark: How to Use Case-Insensitive "Contains"
October 12, 2023 - By default, the contains function in PySpark is case-sensitive.
Databricks
docs.databricks.com › pyspark reference › column › contains
contains (Column) | Databricks on AWS
June 4, 2026 - Column.contains method in PySpark: Check if a string column contains a substring.
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.
Apache
downloads.apache.org › spark › docs › 3.2.2 › api › python › reference › api › pyspark.sql.Column.contains.html
pyspark.sql.Column.contains — PySpark 3.2.2 documentation
>>> df.filter(df.name.contains('o')).collect() [Row(age=5, name='Bob')] pyspark.sql.Column.cast pyspark.sql.Column.desc
Microsoft Learn
learn.microsoft.com › en-us › azure › databricks › pyspark › reference › classes › column › contains
contains (Column) - Azure Databricks | Microsoft Learn
April 17, 2026 - Column.contains method in PySpark: Check if a string column contains a substring.
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 from pyspark.sql.functions provides exactly this capability.