Teradata Package for Python Function Reference | 20.00 - initcap - 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
Product Category
Teradata Vantage
teradataml.dataframe.sql.DataFrameColumn.initcap = initcap()
DESCRIPTION:
    Function modifies a string value in column and returns the string with the first character
    in each word in uppercase and all other characters in lowercase. Words are delimited
    by white space or characters that are not alphanumeric.
 
RAISES:
    TypeError, ValueError, TeradataMlException
 
RETURNS:
    DataFrameColumn
 
EXAMPLES:
    # Load the data to execute 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: Convert the first character to uppercase for strings in "masters" column and
    #            pass it as input to DataFrame.assign().
    >>> result = df.assign(col = df.masters.initcap())
    >>> print(result)
       masters   gpa     stats programming  admitted  col
    id
    3       no  3.70    Novice    Beginner         1   No
    4      yes  3.50  Beginner      Novice         1  Yes
    2      yes  3.76  Beginner    Beginner         0  Yes
    1      yes  3.95  Beginner    Beginner         0  Yes
 
    # Example 2: Executed initcap() function on "masters" column and filtered computed
    #            values which are equal to 'Yes'.
    >>> print(df[df.masters.initcap() == "Yes"])
       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