'pyspark UDF output blank

I have a question with my UDF function: I have a data:raw data

I am writing a code to up case the name column:(input john doe->putout: John Doe)

@F.udf
def coverCase(Str):
    resStr=""
    arr=str.split(" ")
    for x in arr:
        resStr=resStr+ x[0:1].upper()+x[1:len(x)]+" "
    
    return resStr
df.select(coverCase("name")).show()

I have no output output screen shot



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source