pyspark.sql.functions.
format_string
Formats the arguments in printf-style and returns the result as a string column.
format – string that can contain embedded format tags and used as result column’s value
cols – list of column names (string) or list of Column expressions to be used in formatting
Column
>>> df = spark.createDataFrame([(5, "hello")], ['a', 'b']) >>> df.select(format_string('%d %s', df.a, df.b).alias('v')).collect() [Row(v='5 hello')]
New in version 1.5.