Skip to content

LazyColumn.str.find

find

find(sub: str) -> LazyColumn

Returns the first zero-based index of the substring sub in each string, or -1 if not found.

Parameters:

Name Type Description Default
sub str

The substring to search for.

required

Returns:

Name Type Description
LazyColumn LazyColumn

A new LazyColumn of integer values representing the first occurrence of sub. Null entries remain null (or -1 depending on implementation).

Examples:

print(df.head())
#    col1 my_string_column
# 0     1         "Hello"
# 1     2         "abcdef"
# 2     3         "abcabc"
# 3     4         None
# 4     5         "foo"

# Searching for 'lo'
df["my_string_column"].str.find("lo")
# [3, -1, -1, None, -1]