Skip to main content

bit_count

Returns the number of bits that are set in the argument expr as an unsigned 64-bit integer, or NULL if the argument is NULL.

For the corresponding Databricks SQL function, see bit_count function.

Syntax

Python
from pyspark.sql import functions as dbf

dbf.bit_count(col=<col>)

Parameters

Parameter

Type

Description

col

pyspark.sql.Column or str

target column to compute on.

Parameter

Type

Description

col

pyspark.sql.Column or str

target column to compute on.

Returns

pyspark.sql.Column or NULL if the argument is NULL.: the number of bits that are set in the argument expr as an unsigned 64-bit integer,

Examples

Python
from pyspark.sql import functions as dbf
spark.sql("SELECT * FROM VALUES (0), (1), (2), (3), (NULL) AS TAB(value)").select("*", dbf.bit_count("value")).show()