Python Practice › Pandas Programs › Program 71
Uppercase-only check
Write a pandas program to check which values are fully uppercase.
Input
["Kate", "Jason", "ROBERT", "MARK", "Dwyane"]
Output
Name is_upper 0 Kate False 1 Jason False 2 ROBERT True 3 MARK True 4 Dwyane False
Approach
str.isupper().
Solution
import pandas as pddf = pd.DataFrame({"Name": ["Kate", "Jason", "ROBERT", "MARK", "Dwyane"]})df["is_upper"] = df["Name"].str.isupper()print(df)Output
Name is_upper 0 Kate False 1 Jason False 2 ROBERT True 3 MARK True 4 Dwyane False
Learn the concept
New to this topic? Read the lesson, then come back.