| |
- chr(column_expression)
- DESCRIPTION:
Function returns the Latin ASCII character of a given a numeric code value.
PARAMETERS:
column_expression:
Required Argument.
Specifies a ColumnExpression of a numeric column or a numeric constant for
which the Latin ASCII value is to be returned.
Format of a ColumnExpression of a string column: '<dataframe>.<dataframe_column>.expression'.
Notes:
1. If the argument is null, then result is null.
2. Numeric value must be zero or greater. If column_expression is greater than 255,
an operation of column_expression mod 256 is executed to return a value
between 0 and 255.
NOTE:
Function accepts positional arguments only.
EXAMPLES:
# Load the data to run the example.
>>> load_example_data("dataframe", "employee_info")
>>>
# Create a DataFrame on 'employee_info' table.
>>> employee_info = DataFrame("employee_info")
>>> employee_info
first_name marks dob joined_date
employee_no
101 abcde None None 02/12/05
100 abcd None None None
112 None None None 18/12/05
>>>
# Example returns the Latin ASCII character for values in "employee_no" column.
# Import func from sqlalchemy to execute chr function.
>>> from sqlalchemy import func
# Create a sqlalchemy Function object.
>>> chr_func_ = func.chr(employee_info.employee_no.expression)
>>>
# Pass the Function object as input to DataFrame.assign().
>>> df = employee_info.assign(chr_employee_no_=chr_func_)
>>> print(df)
first_name marks dob joined_date chr_employee_no_
employee_no
101 abcde None None 02/12/05 e
100 abcd None None None d
112 None None None 18/12/05 p
>>>
|