pyspark.sql.Column.contains#

Column.contains(other)[source]#

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"])
>>> df.filter(df.name.contains('o')).collect()
[Row(age=5, name='Bob')]