bin

bin #

pyspark.sql.functions.bin(col) #

version: since 1.5.0

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

bin

Runnable Code:

from pyspark.sql import functions as F
# Set up dataframe
data = [{"a": 1,"b": 2},{"a": 3,"b": 2},{"a": 5},{"b": 5}]
df = spark.createDataFrame(data)
df = df.drop("b")
# Use function
df = (df
     .withColumn("bin", 
                 F.bin(F.col("a")))
     )
df.show()
a bin
1 1
3 11
5 101
null null

Usage:

I don’t find myself needing binary very often. But for those that do, the world is yours.



returns: _jvm.functions.bin(_to_java_column(col))

PySpark manual

tags: binary, bin, dumpster




© 2023 PySpark Is Rad