item based Filtering | Teradata Python Package - item based Filtering - Teradata Package for Python

Teradata® Package for Python User Guide

Deployment
VantageCloud
VantageCore
Edition
Enterprise
IntelliFlex
VMware
Product
Teradata Package for Python
Release Number
20.00
Published
March 2024
Language
English (United States)
Last Update
2024-10-10
dita:mapPath
nvi1706202040305.ditamap
dita:ditavalPath
plt1683835213376.ditaval
dita:id
rkb1531260709148
lifecycle
latest
Product Category
Teradata Vantage

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

When axis is 'rows' or 0, the items list specifies the values of the column(s) specified in the index_label of the DataFrame. Only rows where the values of the index column(s) in the items list are returned.

>>> df = DataFrame('admissions_train', index_label = ['programming'])
>>> df
             id masters   gpa     stats admitted
programming                                    
Advanced     15     yes  4.00  Advanced        1
Beginner     34     yes  3.85  Advanced        0
Novice       13      no  4.00  Advanced        1
Beginner     38     yes  2.65  Advanced        1
Novice        5      no  3.44    Novice        0
Beginner     40     yes  3.95    Novice        0
Novice        7     yes  2.33    Novice        1
Beginner     22     yes  3.46    Novice        0
Advanced     26     yes  3.57  Advanced        1
Advanced     17      no  3.83  Advanced        1
>>> df.filter(items = ['Advanced', 'Novice'], axis = 0)
             id masters   gpa     stats admitted
programming                                    
Advanced     15     yes  4.00  Advanced        1
Novice       37      no  3.52    Novice        1
Novice       12      no  3.65    Novice        1
Advanced     17      no  3.83  Advanced        1
Advanced     11      no  3.13  Advanced        1
Advanced     26     yes  3.57  Advanced        1
Novice        5      no  3.44    Novice        0
Novice       24      no  1.87  Advanced        1
Novice       13      no  4.00  Advanced        1
Novice        7     yes  2.33    Novice        1

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

When axis is 'columns' or 1, then column names provided in the items list are selected from the DataFrame.

>>> df.filter(items = ['programming', 'id', 'masters', 'gpa'])
             id masters   gpa
programming                 
Advanced     15     yes  4.00
Novice        7     yes  2.33
Beginner     22     yes  3.46
Advanced     17      no  3.83
Novice       13      no  4.00
Beginner     38     yes  2.65
Advanced     26     yes  3.57
Novice        5      no  3.44
Beginner     34     yes  3.85
Beginner     40     yes  3.95

Supported types for python literals in items

You can specify float, decimal.Decimal, str, bytes, datetime.time, datetime.date, and datetime.datetime python literal types in the items list.