Skip to content

Fuse str.contains() #10

Open
Open
@baziotis

Description

@baziotis

Instance of the original version

df_john = df['Name'].str.contains("John", regex=False)
df_helen = df['Name'].str.contains("Helen", regex=False)

Instance of the faster version

ls_john = []
ls_helen = []
# Do a single pass over the strings
for s in df['Name']:
  ls_john.append("John" in s)
  ls_helen.append("Helen" in s)

ls_john = pd.Series(ls_john)
ls_helen = pd.Series(ls_helen)

Metadata

Metadata

Assignees

No one assigned

    Labels

    patternA pattern that Dias does not already rewrite into a faster version.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions