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| +-------------+----------------+