Skip to main content

contains (Column)

Check if a string column contains a substring.

Syntax

Python
contains(other)

Parameters

Parameter

Type

Description

other

str or Column

String or Column containing the substring to search for

Returns

Column (boolean)

Examples

Python
df = spark.createDataFrame(
[(2, "Alice"), (5, "Bob")], ["age", "name"])
df.filter(df.name.contains('o')).collect()
Output
# [Row(age=5, name='Bob')]