df.filter: Filter Columns Based on a Subset of Their Names
df.filter: Filter Columns Based on a Subset of Their Names
If you want to filter columns of a pandas DataFrame based on characters in their names, use DataFrame.filter. In the example above, we only choose the columns that contain the word “cat”.