Teradata Package for Python Function Reference | 20.00 - to_byte - 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
- lifecycle
- latest
- Product Category
- Teradata Vantage
- teradataml.dataframe.sql.DataFrameColumn.to_byte = to_byte(self, encoding='base10')
- DESCRIPTION:
The function decodes a sequence of characters in a given
encoding into a sequence of bits.
Note:
* By default, consider DataFrame column as 'base10' and encodes
into a sequence of bits.
PARAMETERS:
encoding:
Optional Argument.
Specifies encoding "to_byte" uses to return the sequence of characters
specified by column.
The following encodings are supported:
* BaseX
* BaseY
* Base64M (MIME)
* ASCII
where X is a power of 2 (for example, 2, 8, 16) and
Y is not a power of 2 (for example, 10 and 36).
Default Value: 'base10'
Types: str
Returns:
ColumnExpression.
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'
# Example 1: Converts values in "id_col" to bytes and pass it as input to
# DataFrame.assign().
>>> byte_df = df.assign(byte_col = df.id_col.to_byte())
>>> print(byte_df)
byte_col varbyte_col blob_col byte_col
id_col
2 b'61' b'627A7863' b'6162636431323233...' b'2'
1 b'62' b'616263643132' b'3331363136323633...' b'1'
0 b'63' b'62717765' b'3330363136323633...' b''
>>>