pyspark.sql.functions.conv#
- pyspark.sql.functions.conv(col, fromBase, toBase)[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
Columnor str a column to convert base for.
- fromBase: int
 from base number.
- toBase: int
 to base number.
- col
 - Returns
 Columnlogariphm of given value.
Examples
>>> from pyspark.sql import functions as sf >>> df = spark.createDataFrame([("010101",), ( "101",), ("001",)], ['n']) >>> df.select("*", sf.conv(df.n, 2, 16)).show() +------+--------------+ | n|conv(n, 2, 16)| +------+--------------+ |010101| 15| | 101| 5| | 001| 1| +------+--------------+