pyspark.sql.functions.decode¶
-
pyspark.sql.functions.
decode
(col: ColumnOrName, charset: str) → pyspark.sql.column.Column[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’).
New in version 1.5.0.
Changed in version 3.4.0: Supports Spark Connect.
- Parameters
- col
Column
or str target column to work on.
- charsetstr
charset to use to decode to.
- col
- Returns
Column
the column for computed results.
Examples
>>> df = spark.createDataFrame([('abcd',)], ['a']) >>> df.select(decode("a", "UTF-8")).show() +----------------+ |decode(a, UTF-8)| +----------------+ | abcd| +----------------+