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

using loc with upper()

I’m trying to bring back all values that, in upper case, equal "EU". My solution below doesn’t work. Does anybody know how I would do this?

companies_df.loc[(upper(companies_df["location"]) == 'EU')].head(10)

>Solution :

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

The issue with your code is that the upper function is not applied correctly to the location column. In pandas, you can use the str accessor to apply string methods to a column.

companies_df.loc[companies_df["location"].str.upper() == 'EU'].head(10)
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