regex Filtering | Teradata Python Package - regex Filtering - Teradata Vantage

Teradata® VantageCloud Lake

Deployment
VantageCloud
Edition
Lake
Product
Teradata Vantage
Published
January 2023
Language
English (United States)
Last Update
2024-04-03
dita:mapPath
phg1621910019905.ditamap
dita:ditavalPath
pny1626732985837.ditaval
dita:id
phg1621910019905

Example 1: 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].*s', axis = 'columns')
  masters     stats
0     yes  Advanced
1     yes    Novice
2     yes    Novice
3      no  Advanced
4      no  Advanced
5     yes  Advanced
6     yes  Advanced
7      no    Novice
8     yes  Advanced
9     yes    Novice

Example 2: 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 = '^Beg.+', axis = 0)
             id masters   gpa     stats admitted
programming                                    
Beginner     21      no  3.87    Novice        1
Beginner     22     yes  3.46    Novice        0
Beginner     39     yes  3.75  Advanced        0
Beginner     34     yes  3.85  Advanced        0
Beginner     38     yes  2.65  Advanced        1
Beginner      3      no  3.70    Novice        1
Beginner      1     yes  3.95  Beginner        0
Beginner     32     yes  3.46  Advanced        0
Beginner     40     yes  3.95    Novice        0
Beginner     29     yes  4.00    Novice        0