Teradata Package for Python Function Reference on VantageCloud Lake - countset - 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
- ft:locale
- en-US
- ft:lastEdition
- 2024-12-19
- dita:id
- TeradataPython_FxRef_Lake_2000
- Product Category
- Teradata Vantage
- teradataml.dataframe.sql.DataFrameColumn.countset = countset(target_value)
- DESCRIPTION:
Function returns the count of the binary bits within the integer or byte value column
that are either set to 1 or set to 0, depending on the "target_value" value.
PARAMETERS:
target_value:
Optional Argument.
Specifies a ColumnExpression of an integer column or an integer literal representing
a binary bit value, 0 or 1, to be counted within the integer or byte value column.
Notes:
1. If the argument is NULL, the function returns NULL.
Format of a ColumnExpression of a column: '<dataframe>.<dataframe_column>'.
Default Value: 1
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: Counts number of 0's within values of "varbyte_col" column.
# and pass it as input to DataFrame.assign().
>>> res_df = df.assign(col= df.varbyte_col.countset(0))
>>> print(res_df)
byte_col varbyte_col blob_col col
id_col
2 b'61' b'616263643132' b'6162636431323233' 29
1 b'62' b'62717765' b'3331363136323633' 15
0 b'63' b'627A7863' b'3330363136323633' 16