Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

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 :

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

Name Index1 Index2
AAA 67 70
BBB 84 45

>Solution :

Use isupper from pandas:

df = df.loc[df["Name"].str.isupper(), :]
Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading