Created
January 24, 2019 12:48
-
-
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
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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