Skip to content
Advertisement

How to extract all uppercase row to a new data frame

I have a pandas data frame which looks like this

Name Index1 Index2
AAA 67 70
Aaa 55 80
Abb 32 20
BBB 84 45
Baa 80 70
Bbb 13 40

where some rows have names with all uppercase and some with lowercase. How can i create another dataframe with only the uppercase rows

expected output will be :

Name Index1 Index2
AAA 67 70
BBB 84 45

Advertisement

Answer

Use isupper from pandas:

df = df.loc[df["Name"].str.isupper(), :]
User contributions licensed under: CC BY-SA
9 People found this is helpful
Advertisement