pyspark.sql.functions.decode#
- pyspark.sql.functions.decode(col, charset)[source]#
Computes the first argument into a string from a binary using the provided character set (one of βUS-ASCIIβ, βISO-8859-1β, βUTF-8β, βUTF-16BEβ, βUTF-16LEβ, βUTF-16β, βUTF-32β).
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.
- charsetliteral string
charset to use to decode to.
- col
- Returns
Column
the column for computed results.
See also
Examples
>>> from pyspark.sql import functions as sf >>> df = spark.createDataFrame([(b"abcd",)], ["a"]) >>> df.select("*", sf.decode("a", "UTF-8")).show() +-------------+----------------+ | a|decode(a, UTF-8)| +-------------+----------------+ |[61 62 63 64]| abcd| +-------------+----------------+