pyspark.sql.functions.bin#

pyspark.sql.functions.bin(col)[source]#

Returns the string representation of the binary value of the given column.

New in version 1.5.0.

Changed in version 3.4.0: Supports Spark Connect.

Parameters
colColumn or str

target column to work on.

Returns
Column

binary representation of given value as string.

Examples

>>> df = spark.createDataFrame([2,5], "INT")
>>> df.select(bin(df.value).alias('c')).collect()
[Row(c='10'), Row(c='101')]