Teradata Package for Python Function Reference on VantageCloud Lake - ltrim - 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 on VantageCloud Lake
- Deployment
- VantageCloud
- Edition
- Lake
- Product
- Teradata Package for Python
- Release Number
- 20.00.00.03
- Published
- December 2024
- ft:locale
- en-US
- ft:lastEdition
- 2024-12-19
- dita:id
- TeradataPython_FxRef_Lake_2000
- Product Category
- Teradata Vantage
- teradataml.dataframe.sql.DataFrameColumn.ltrim = ltrim(expression=' ')
- DESCRIPTION:
Function returns the string values in column, with its left-most characters removed up
to the first character that is not in the string value in argument.
PARAMETERS:
expression:
Optional Argument.
Specifies a ColumnExpression of a string column or a string literal that
will be removed from string values in column. If "expression" is specified, it must
be the same data type as string values in column.
Format of a ColumnExpression of a string column: '<dataframe>.<dataframe_column>'.
Default Value: ' '
NOTES:
Column expression of both arguments can be of following type:
a. Character/String types: CHAR, VARCHAR, or CLOB
b. Integer types: BYTEINT, SMALLINT, INTEGER, or BIGINT
c. Numeric types: FLOAT, REAL, DOUBLE PRECISION, DECIMAL, NUMERIC, or NUMBER
RAISES:
TypeError, ValueError, TeradataMlException
RETURNS:
DataFrameColumn
EXAMPLES:
# Load the data to run the example.
>>> load_example_data("dataframe", "admissions_train")
# Create a DataFrame on 'admissions_train' table.
>>> 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: Left trim string in "stats" column if it has 'Begi' and pass it as
# input to DataFrame.assign().
>>> res = df.assign(col = df.stats.ltrim("Begi"))
>>> print(res)
masters gpa stats programming admitted col
id
3 no 3.70 Novice Beginner 1 Novice
4 yes 3.50 Beginner Novice 1 nner
2 yes 3.76 Beginner Beginner 0 nner
1 yes 3.95 Beginner Beginner 0 nner
# Example 2: Executed ltrim() function on "stats" column and filtered computed
# values which are equal to 'nner'.
>>> print(df[df.stats.ltrim("Begi") == "nner"])
masters gpa stats programming admitted
id
4 yes 3.50 Beginner Novice 1
2 yes 3.76 Beginner Beginner 0
1 yes 3.95 Beginner Beginner 0