Teradata Package for Python Function Reference | 20.00 - rpad - 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.03
Published
December 2024
ft:locale
en-US
ft:lastEdition
2024-12-19
dita:id
TeradataPython_FxRef_Enterprise_2000
lifecycle
latest
Product Category
Teradata Vantage
teradataml.dataframe.sql.DataFrameColumn.rpad = rpad(length, fill_string=' ')
DESCRIPTION:
    Function returns the string value in column padded to the right with the characters
    in "fill_string" so that the resulting string has "length" characters.
 
PARAMETERS:
    length:
        Required Argument.
        Specifies a ColumnExpression of an int column or an integer literal specifying
        the number of characters in the resulting string.
        Format of a ColumnExpression of a string column: '<dataframe>.<dataframe_column>'.
        Supported column types: INTEGER, BIGINT, or NUMBER
        Types: ColumnExpression, int
 
    fill_string:
        Optional Argument.
        Specifies a ColumnExpression of a string column or a string literal
        used to pad the source_string.
        The sequence of characters in fill_string is replicated as necessary.
        Format of a ColumnExpression of a string column: '<dataframe>.<dataframe_column>'.
        Supported column types: CHAR, VARCHAR, or CLOB
        Default Value: ' '
        Types: ColumnExpression, str
 
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: Pad string in "stats" column with 0 and pass it as input to DataFrame.assign().
    >>> res = df.assign(col = df.stats.rpad(10, "0"))
    >>> print(res)
       masters   gpa     stats programming  admitted         col
    id
    3       no  3.70    Novice    Beginner         1  Novice0000
    4      yes  3.50  Beginner      Novice         1  Beginner00
    2      yes  3.76  Beginner    Beginner         0  Beginner00
    1      yes  3.95  Beginner    Beginner         0  Beginner00
 
    # Example 2: Pad string in "stats" column with strings from "masters" column and pass it
    #            as input to DataFrame.assign().
    >>> df = df.assign(lpad_gpa_ = df.stats.rpad(20, df.masters))
    >>> print(df)
       masters   gpa     stats programming  admitted                   col
    id
    3       no  3.70    Novice    Beginner         1  Novicenonononononono
    4      yes  3.50  Beginner      Novice         1  Beginneryesyesyesyes
    2      yes  3.76  Beginner    Beginner         0  Beginneryesyesyesyes
    1      yes  3.95  Beginner    Beginner         0  Beginneryesyesyesyes