Teradata Package for Python Function Reference on VantageCloud Lake - endswith - 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.endswith = endswith(self, other)
DESCRIPTION:
    Function to check whether the column value ends with the specified value or not.
 
PARAMETERS:
    other:
        Required Argument.
        Specifies a string literal or ColumnExpression to match.
        Types: str OR ColumnExpression
 
RETURNS:
    ColumnExpression.
 
EXAMPLES:
    >>> load_example_data("ntree", "employee_table")
    >>> df = DataFrame("employee_table")
    >>> df = df.assign(new_col = 'on')
           emp_name  mgr_id mgr_name new_col
    emp_id
    300       Donna   100.0      Don      on
    500        Fred   400.0      Kim      on
    100         Don     NaN       NA      on
    400         Kim   200.0      Pat      on
    200         Pat   100.0      Don      on
 
    # Example 1: Find out the employees whose manager name ends
    #            with values in column 'new_col'.
    >>> df[df.mgr_name.endswith(df.new_col)]
           emp_name  mgr_id mgr_name new_col
    emp_id
    300       Donna     100      Don      on
    200         Pat     100      Don      on
 
    # Example 2: Find out the employees whose name starts with
    #            'D' and ends with 'n'.
    >>> df[df.emp_name.startswith('D') & df.emp_name.endswith('n')]
           emp_name mgr_id mgr_name new_col
    emp_id
    100         Don   None       NA      on
 
    # Example 3: Create a new column with values as
    #            1, if employees manager name ends with 'im'.
    #            0, else.
    >>> df.assign(new_col=case_when((df.mgr_name.endswith('im').expression, 1), else_=0))
           emp_name  mgr_id mgr_name new_col
    emp_id
    300       Donna   100.0      Don       0
    500        Fred   400.0      Kim       1
    100         Don     NaN       NA       0
    400         Kim   200.0      Pat       0
    200         Pat   100.0      Don       0