In Synapse Notebook using pyspark inbuilt functions how to convert country code to country name as description
SaiSekhar, MahasivaRavi (Philadelphia)
60
Reputation points
Hi Team,
Could you please help us that how to change country code to country name (as description) for a column in synapse notebook using pyspark (modules or libraries) could you please share the code.
we have used below but it is not working.
Eg:
import country_converter as coco
from pyspark.sql.types import StringType
from pyspark.sql.functions import udf, lit,col
def country_converter(country):
if country:
return coco.convert(country, to='IS02', not_found=None)
return None
cc_udf = udf(country_converter, StringType())
Sign in to answer