Skip to main content
PYSPARK • LESSON 49

Uppercase Conversion with upper()

How do we standardize country codes to uppercase for consistent dimensional joining?

Intermediate2 Minutes280 XP
🤔 THE QUESTION

How do we standardize country codes to uppercase for consistent dimensional joining?

💡 WHAT IS IT?

upper() converts all alphabetic characters in a string Column to uppercase.

🎯 WHAT IS IT USED FOR?

Standardizing ISO country codes, currency codes, state abbreviations, and lookup join keys.

💻 EXAMPLE
from pyspark.sql.functions import col, upper

df = df.withColumn("country_code", upper(col("country")))

🎯 Mission Objectives

Practice typing production-grade PySpark code for Uppercase Conversion with upper().

  • Import upper string function
  • Convert country strings to uppercase
  • Ensure standardized join keys