Teradata Package for Python Function Reference | 20.00 - bit_xor - 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.bit_xor = bit_xor(bit_mask)
DESCRIPTION:
    Function performs a bitwise XOR operation on the binary representation of the
    integer or byte column and corresponding bits from input argument.
    Function takes two bit patterns of equal length and performs the exclusive OR
    operation on each pair of corresponding bits as follows:
        * The result in each position is 1 if the two bits are different.
        * The result in each position is 0 if the two bits are same.
    If the binary representation of the integer or byte value in column and "bit_mask"
    argument differ in length, the arguments are processed as follows:
        * The value in column and "bit_mask" arguments are aligned on their least
          significant byte/bit.
        * The smaller argument is padded with zeros to the left until it becomes
          the same size as the larger argument.
 
ALTERNATE NAME:
    bitxor
 
PARAMETERS:
    bit_mask:
        Required Argument.
        Specifies a ColumnExpression of an integer or byte column or a numeric or byte
        literal value.
        Note:
            1. If the argument is NULL, the function returns NULL.
        Format of a ColumnExpression of a column: '<dataframe>.<dataframe_column>'.
        Types:
            ColumnExpression, int
            The data type of the "bit_mask" parameter varies depending upon the data type
            of the integer or byte column. The following table shows the supported column/literal
            value types for integer or byte column and "bit_mask" parameters and their permitted
            combinations:
             ===============================================
            | value of column type | bit_mask type          |
             ===============================================
            | BYTEINT              | BYTE(1) or BYTEINT     |
            | SMALLINT             | BYTE(2) or SMALLINT    |
            | INTEGER              | BYTE(4) or INTEGER     |
            | BIGINT               | BYTE(8) or BIGINT      |
            | VARBYTE(n)           | VARBYTE(n)             |
             ===============================================
 
RAISES:
    TypeError, ValueError, TeradataMlException
 
RETURNS:
    DataFrameColumn
 
EXAMPLES:
    # Load the data to run the example.
    >>> load_example_data("dataframe", "bytes_table")
 
    # Create a DataFrame on 'bytes_table' table.
    >>> df = DataFrame("bytes_table")
    >>> print(df)
           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'
 
    # Example1: Performs bitxor operation on "id" and "byte_col" columns and pass
    #           it as input to DataFrame.assign().
    >>> res_df = df.assign(col = df.id_col.bit_xor(df.byte_col))
    >>> print(res_df)
           byte_col      varbyte_col             blob_col         col
    id_col
    2         b'61'  b'616263643132'  b'6162636431323233'  1627389954
    1         b'62'      b'62717765'  b'3331363136323633'  1644167169
    0         b'63'      b'627A7863'  b'3330363136323633'  1660944384