Skip to main content
PYSPARK โ€ข LESSON 49

Uppercase Conversion with upper()

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

Intermediateโฑ 2 Minutesโญ 280 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