Teradata Package for Python Function Reference on VantageCloud Lake | 17.20 - shiftright - 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
17.20
Publication Date
November 2022
Content Type
Programming Reference
Publication ID
B700-4500-112K
ft:locale
en-US
ft:lastEdition
2024-02-21
ft:sourceId
FTML
dita:id
TeradataPython_FxRef_Lake_1720
Product Category
Teradata Vantage
teradataml.dataframe.sql.DataFrameColumn.shiftright = shiftright(bit_mask)
DESCRIPTION:
    Function returns the integer or byte value of column shifted by the specified
    number of bits ("bit_mask") to the right. The bits in the most significant
    positions are lost, and the bits in the least significant positions are
    filled with zeros.
 
PARAMETERS:
    bit_mask:
        Required Argument.
        Specifies a ColumnExpression of an integer column or an integer literal
        indicating the number of bit positions to shift.
        Notes:
        1. If "bit_mask" is equal to zero, then the function returns integer or byte
           value of column unchanged.
        2. If "bit_mask" is negative, then the function shifts the bits to the right
           instead of the right.
        3. If integer or byte value of column and/or "bit_mask" are NULL, then the
           function returns NULL.
        4. The scope of the shift operation is bounded by the size of the integer or byte
           value of column. Specifying a shift that is outside the range of integer or byte
           value of column results in an error.
        Format of a ColumnExpression of a column: '<dataframe>.<dataframe_column>'.
        Types: ColumnExpression, int
 
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: Shifts values in "varbyte_col" column to right by 3 bits and
    #           pass it as input to DataFrame.assign().
    >>> res_df = df.assign(col= df.varbyte_col.shiftright(3))
    >>> print(res_df)
           byte_col      varbyte_col             blob_col             col
    id_col
    0         b'63'      b'627A7863'  b'3330363136323633'      b'C4F4F0C'
    2         b'61'  b'616263643132'  b'6162636431323233'  b'C2C4C6C8626'
    1         b'62'      b'62717765'  b'3331363136323633'      b'C4E2EEC'