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 column name

target column to work on.

Returns
Column

binary representation of given value as string.

Examples

>>> import pyspark.sql.functions as sf
>>> spark.range(10).select("*", sf.bin("id")).show()
+---+-------+
| id|bin(id)|
+---+-------+
|  0|      0|
|  1|      1|
|  2|     10|
|  3|     11|
|  4|    100|
|  5|    101|
|  6|    110|
|  7|    111|
|  8|   1000|
|  9|   1001|
+---+-------+