In Synapse Notebook using pyspark inbuilt functions how to convert country code to country name as description

2025-01-17T09:13:38.3733333+00:00

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())
Azure Synapse Analytics
Azure Synapse Analytics
An Azure analytics service that brings together data integration, enterprise data warehousing, and big data analytics. Previously known as Azure SQL Data Warehouse.
5,135 questions
Azure Databricks
Azure Databricks
An Apache Spark-based analytics platform optimized for Azure.
2,305 questions
{count} votes

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.