Teradata Package for Python Function Reference on VantageCloud Lake - bit_or - 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 on VantageCloud Lake
- Deployment
- VantageCloud
- Edition
- Lake
- Product
- Teradata Package for Python
- Release Number
- 20.00.00.03
- Published
- December 2024
- Language
- English (United States)
- Last Update
- 2024-12-19
- dita:id
- TeradataPython_FxRef_Lake_2000
- Product Category
- Teradata Vantage
- teradataml.dataframe.sql.DataFrameColumn.bit_or = bit_or(bit_mask)
- DESCRIPTION:
Function performs the logical OR operation on the binary representation of the
integer or byte value in column and corresponding bits from input argument.
Function takes two bit patterns of equal length and performs the logical OR
operation on each pair of corresponding bits as follows:
* The result is 1 if either of the two bits are 1.
* The result is 0 if both the bits are 0.
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:
bitor
PARAMETERS:
bit_mask:
Required Argument.
Specifies a ColumnExpression of a numeric 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 bits in column. The following table shows the supported column/literal
value types for bits in column and "bit_mask" parameters and their permitted
combinations:
===================================================
| bits in 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 |
| NUMBER(38,0) | VARBYTE(16) or NUMBER(38,0) |
| 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 bit_or operation on "id" and "byte_col" columns and
# and pass it as input to DataFrame.assign().
>>> res_df = df.assign(col=df.id_col.bit_or(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