Teradata Package for Python Function Reference - bitnot - 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

Product
Teradata Package for Python
Release Number
17.00
Published
November 2021
Language
English (United States)
Last Update
2021-11-19
lifecycle
previous
Product Category
Teradata Vantage
 
 
bitnot

 
Functions
       
bitnot(target_arg)
DESCRIPTION:
    Function performs a bitwise complement on the binary representation of the input argument.
    The bitwise NOT, or complement, is a unary operation which performs logical negation on
    each bit, forming the ones' complement of the specified binary value. The digits in the
    argument which were 0 become 1, and vice versa.
 
PARAMETERS:
    target_arg:
        Required Argument.
        Specifies a ColumnExpression of an integer or byte column or a numeric or byte
        literal value.
        If the argument is NULL, the function returns NULL.
        Format of a ColumnExpression of a column: '<dataframe>.<dataframe_column>.expression'.
        Supported SQL column types: BYTEINT, SMALLINT, INTEGER, BIGINT, and VARBYTE(n)
 
NOTE:
    Function accepts positional arguments only.
 
EXAMPLES:
    # Load the data to run the example.
    >>> load_example_data("dataframe", "bytes_table")
    >>>
 
    # Create a DataFrame on 'bytes_table' table.
    >>> bytes_table = DataFrame("bytes_table")
    >>> bytes_table
           byte_col      varbyte_col             blob_col
    id_col
    2         b'61'  b'616263643132'  b'6162636431323233'
    1         b'62'      b'62717765'  b'3331363136323633'
    0         b'63'      b'627A7863'  b'3330363136323633'
    >>>
 
    # Example performs a bitwise complement operation on "varbyte_col" column.
    # Import func from sqlalchemy to execute bitnot function.
    >>> from sqlalchemy import func
 
    # Create a sqlalchemy Function object.
    # Note: Function name case does not matter. We can use the function name in
    #       lower case, upper case or mixed case.
    >>> bit_byte_func_ = func.BITNOT(bytes_table.varbyte_col.expression)
    >>>
 
    # Pass the Function object as input to DataFrame.assign().
    >>> df = bytes_table.assign(bitnot_byte_=bit_byte_func_)
    >>> print(df)
           byte_col      varbyte_col             blob_col      bitnot_byte_
    id_col
    2         b'61'  b'616263643132'  b'6162636431323233'  b'-616263643133'
    1         b'62'      b'62717765'  b'3331363136323633'      b'-62717766'
    0         b'63'      b'627A7863'  b'3330363136323633'      b'-627A7864'
    >>>