pyspark.sql.functions.base64#
- pyspark.sql.functions.base64(col)[source]#
Computes the BASE64 encoding of a binary column and returns it as a string column.
New in version 1.5.0.
Changed in version 3.4.0: Supports Spark Connect.
- Parameters
- col
Column
or column name target column to work on.
- col
- Returns
Column
BASE64 encoding of string value.
See also
Examples
>>> from pyspark.sql import functions as sf >>> df = spark.createDataFrame(["Spark", "PySpark", "Pandas API"], "STRING") >>> df.select("*", sf.base64("value")).show() +----------+----------------+ | value| base64(value)| +----------+----------------+ | Spark| U3Bhcms=| | PySpark| UHlTcGFyaw==| |Pandas API|UGFuZGFzIEFQSQ==| +----------+----------------+