Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fuse str.contains() #10

Open
baziotis opened this issue Aug 16, 2023 · 0 comments
Open

Fuse str.contains() #10

baziotis opened this issue Aug 16, 2023 · 0 comments
Labels
pattern A pattern that Dias does not already rewrite into a faster version.

Comments

@baziotis
Copy link
Collaborator

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)
@baziotis baziotis added the pattern A pattern that Dias does not already rewrite into a faster version. label Aug 16, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
pattern A pattern that Dias does not already rewrite into a faster version.
Projects
None yet
Development

No branches or pull requests

1 participant