Created
January 6, 2020 23:21
-
-
Save fnneves/68d1f22c8e604e5c2dfe66f4e37d2296 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
| def df_filter(df, string): | |
| new = df.filter(regex=string) | |
| return new | |
| # Example | |
| data = [{'2018_inc': 10, '2019_inc': 12, '2018_rev':23}, {'2018_inc':10, '2019_inc': 20, '2018_rev': 30}] | |
| df = pd.DataFrame(data) | |
| y_2018 = df_filter(df, '2018') # getting all columns with 2018 in their names |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment