Teradata Package for Python Function Reference | 20.00 - ilike - Teradata Package for Python - Look here for syntax, methods and examples for the functions included in the Teradata Package for Python.
Teradata® Package for Python Function Reference - 20.00
- Deployment
- VantageCloud
- VantageCore
- Edition
- Enterprise
- IntelliFlex
- VMware
- Product
- Teradata Package for Python
- Release Number
- 20.00.00.02
- Published
- September 2024
- Language
- English (United States)
- Last Update
- 2024-10-17
- dita:id
- TeradataPython_FxRef_Enterprise_2000
- Product Category
- Teradata Vantage
- teradataml.dataframe.sql.DataFrameColumn.ilike = ilike(self, other)
- DESCRIPTION:
Function which is used to match the pattern.
PARAMETERS:
other:
Required Argument.
Specifies a string to match. String match is case insensitive.
Types: str
RETURNS:
ColumnExpression.
EXAMPLES:
>>> load_example_data("dataframe","admissions_train")
>>> df = DataFrame.from_table('admissions_train')
masters gpa stats programming admitted
id
13 no 4.00 Advanced Novice 1
26 yes 3.57 Advanced Advanced 1
5 no 3.44 Novice Novice 0
19 yes 1.98 Advanced Advanced 0
15 yes 4.00 Advanced Advanced 1
40 yes 3.95 Novice Beginner 0
7 yes 2.33 Novice Novice 1
22 yes 3.46 Novice Beginner 0
36 no 3.00 Advanced Novice 0
38 yes 2.65 Advanced Beginner 1
# Example 1: Find out the records whose stats starts with 'A'.
>>> df = df[df.stats.ilike('a%')]
>>> df
masters gpa stats programming admitted
id
19 yes 1.98 Advanced Advanced 0
15 yes 4.00 Advanced Advanced 1
38 yes 2.65 Advanced Beginner 1
26 yes 3.57 Advanced Advanced 1
17 no 3.83 Advanced Advanced 1
34 yes 3.85 Advanced Beginner 0
13 no 4.00 Advanced Novice 1
24 no 1.87 Advanced Novice 1
36 no 3.00 Advanced Novice 0
27 yes 3.96 Advanced Advanced 0
>>>
# Example 2: Create a new Column with values as -
# 1 if value of column 'stats' starts with 'a' and third letter is 'v',
# 0 otherwise. Ignore case.
>>> df.assign(new_col = case_when((df.stats.ilike('a_v%').expression, 1), else_=0))
masters gpa stats programming admitted n
id
13 no 4.00 Advanced Novice 1 1
26 yes 3.57 Advanced Advanced 1 1
5 no 3.44 Novice Novice 0 0
19 yes 1.98 Advanced Advanced 0 1
15 yes 4.00 Advanced Advanced 1 1
40 yes 3.95 Novice Beginner 0 0
7 yes 2.33 Novice Novice 1 0
22 yes 3.46 Novice Beginner 0 0
36 no 3.00 Advanced Novice 0 1
38 yes 2.65 Advanced Beginner 1 1
>>>