regex Filtering

Teradata® Python Package User Guide

brand
Teradata Vantage
prodname
Teradata Python Package
vrm_release
16.20
category
User Guide
featnum
B700-4006-098K

Example: Filtering with axis set to 'columns' or 1

When axis is 'columns' or 1, then the regex pattern is applied to the column names of the DataFrame.

df.filter(regex='[a-z].*Width', axis = 'columns')
 
 
   SepalWidth  PetalWidth
0         3.2         2.3
1         2.6         2.3
2         2.8         1.3
3         3.0         1.2
4         2.5         1.5
5         3.0         2.1
6         3.0         2.3
7         2.4         1.0
8         2.4         1.1
9         3.5         0.3

Example: Filtering with axis set to 'rows' or 0

When axis is 'rows' or 0, then the regex pattern is applied to the values of the columns specified in the index_label of the DataFrame.
The index columns will be cast into VARCHAR columns in order to perform the match.
df.filter(regex = 'Iris-[s]+', axis = 'rows')
 
 
             SepalLength  SepalWidth  PetalLength  PetalWidth
Name                                                                      
Iris-setosa          5.4         3.9          1.7         0.4            
Iris-setosa          5.1         3.8          1.5         0.3           
Iris-setosa          5.5         3.5          1.3         0.2           
Iris-setosa          5.1         3.5          1.4         0.3           
Iris-setosa          4.3         3.0          1.1         0.1           
Iris-setosa          5.0         3.5          1.3         0.3           
Iris-setosa          5.0         3.4          1.5         0.2           
Iris-setosa          4.6         3.6          1.0         0.2           
Iris-setosa          4.9         3.1          1.5         0.1           
Iris-setosa          5.1         3.5          1.4         0.2