Teradata Package for Python Function Reference | 20.00 - hex - 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
Published
March 2024
Language
English (United States)
Last Update
2024-04-10
dita:id
TeradataPython_FxRef_Enterprise_2000
Product Category
Teradata Vantage
teradataml.dataframe.sql.DataFrameColumn.hex = hex(self)
DESCRIPTION:
    Function to compute the Hexadecimal from decimal for the column.
 
RETURNS:
    ColumnExpression.
 
EXAMPLES:
    # Load the data to run the example.
    >>> load_example_data("teradataml","titanic")
 
    # Create a DataFrame on 'titanic' table.
    >>> titanic = DataFrame.from_table('titanic')
    >>> df = titanic.select(["passenger", "age", "fare"])
    >>> print(df)
                age      fare
    passenger
    326        36.0  135.6333
    183         9.0   31.3875
    652        18.0   23.0000
    265         NaN    7.7500
    530        23.0   11.5000
    122         NaN    8.0500
    591        35.0    7.1250
    387         1.0   46.9000
    734        23.0   13.0000
    795        25.0    7.8958
    >>>
 
    # Example 1: Converts values in "age" decimal to hexadecimal and pass it as input to
    #            DataFrame.assign().
    >>> hex_df = df.assign(age_in_hex=df.age.hex())
    >>> print(hex_df)
                age    fare age_in_hex
    passenger
    530        23.0  11.500         17
    591        35.0   7.125         23
    387         1.0  46.900          1
    856        18.0   9.350         12
    244        22.0   7.125         16
    713        48.0  52.000         30
    448        34.0  26.550         22
    122         NaN   8.050       None
    734        23.0  13.000         17
    265         NaN   7.750       None
    >>>