notebook - pyspark expression

arkiboys 9,646 Reputation points
2021-12-15T16:56:50.307+00:00

Hello,

This pyspark code as you see below, converts the Contact field values to upper case.

from pyspark.sql.functions import expr

vExpression = 'upper'
vCDF = (
vCDF
.withColumn("Contact",upper('Contact'))
)

display(vvCDF.limit(10))


Question:
How is it possible to use the variable vExpression to upper case the Contact field values so that I do not have to type upper in the .withColumn section?

Thank you

.NET
.NET
Microsoft Technologies based on the .NET software framework.
3,415 questions
0 comments No comments
{count} votes