Skip to content

LazyColumn.str.contains

contains

contains(pat: str) -> LazyColumn

Checks whether each string contains a specified substring.

Parameters:

Name Type Description Default
pat str

The substring to look for.

required

Returns:

Name Type Description
LazyColumn LazyColumn

A new LazyColumn of boolean values indicating whether each string contains pat. Null entries remain null (or False depending on implementation).

Examples:

print(df.head())
#    col1 my_string_column
# 0     1         "Hello"
# 1     2         "World"
# 2     3         "Test123"
# 3     4         None
# 4     5         "hello world"

df["my_string_column"].str.contains("lo")
# [True, False, False, None, True]