Skip to content

Instantly share code, notes, and snippets.

@jobel-code
Created January 24, 2019 12:48
Show Gist options
  • Save jobel-code/c3151a840394b39e2a3c8a1f4b6db4dd to your computer and use it in GitHub Desktop.
Save jobel-code/c3151a840394b39e2a3c8a1f4b6db4dd to your computer and use it in GitHub Desktop.
regex find all columns in a pandas dataframe if the column includes matching text
import re
r = re.compile("depth", re.IGNORECASE)
# regex to find all the columns names that matches depth at any place in the string.
depth_cols = sorted(list(filter(r.search, subset_df)))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment