Teradata Package for Python Function Reference | 20.00 - right - 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.right = right(length)
- DESCRIPTION:
Function truncates string value in column to a specified number of characters desired from
the right side of the string.
PARAMETERS:
length:
Required Argument.
Specifies a positive integer specifying the number of characters desired from
the left side of the string. If the number of character exceeds the number of
characters in the original string, the original string is returned.
Format of a ColumnExpression of a string column: '<dataframe>.<dataframe_column>'.
Types: ColumnExpression, int
RAISES:
TypeError, ValueError, TeradataMlException
RETURNS:
DataFrameColumn
EXAMPLES:
# Load the data to run the example.
>>> load_example_data("dataframe", "admissions_train")
>>> df = DataFrame("admissions_train").iloc[:4]
>>> print(df)
masters gpa stats programming admitted
id
3 no 3.70 Novice Beginner 1
4 yes 3.50 Beginner Novice 1
2 yes 3.76 Beginner Beginner 0
1 yes 3.95 Beginner Beginner 0
# Example 1: Truncates values in "programming" column to a length of 3 and pass it
# as input to DataFrame.assign().
>>> res = df.assign(col = df.programming.right(3))
>>> print(res)
masters gpa stats programming admitted col
id
3 no 3.70 Novice Beginner 1 ner
4 yes 3.50 Beginner Novice 1 ice
2 yes 3.76 Beginner Beginner 0 ner
1 yes 3.95 Beginner Beginner 0 ner
# Example 2: Executed right() function on "programming" column and filtered computed
# values which are equal to 'ner'.
>>> print(df[df.programming.right(3) == "ner"])
masters gpa stats programming admitted
id
3 no 3.70 Novice Beginner 1
2 yes 3.76 Beginner Beginner 0
1 yes 3.95 Beginner Beginner 0