contains (Column)

检查字符串列是否包含子字符串。

Syntax

contains(other)

参数

参数 类型 Description
other str 或 Column 包含要搜索的子字符串的字符串或列

退货

列(布尔值)

示例

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