Python Practice › Pandas Programs › Program 71

Uppercase-only check

EasyPandas Programs · 71 of 95

Write a pandas program to check which values are fully uppercase.

Advertisement
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

  1. str.isupper().

Solution

Python
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
Advertisement

Learn the concept

New to this topic? Read the lesson, then come back.

More pandas programs

← All 95 Pandas Programs