pyspark.sql.functions.conv¶
-
pyspark.sql.functions.
conv
(col: ColumnOrName, fromBase: int, toBase: int) → pyspark.sql.column.Column[source]¶ Convert a number in a string column from one base to another.
New in version 1.5.0.
Changed in version 3.4.0: Supports Spark Connect.
- Parameters
- col
Column
or str a column to convert base for.
- fromBase: int
from base number.
- toBase: int
to base number.
- col
- Returns
Column
logariphm of given value.
Examples
>>> df = spark.createDataFrame([("010101",)], ['n']) >>> df.select(conv(df.n, 2, 16).alias('hex')).collect() [Row(hex='15')]