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

Search return empty result in python

I have this data frame:

df:

id hint
29c45630-7d41-11e9-8ea2-9f2bfe5760ab None
61afc910-3918-11ea-b078-93fcef773138 Yes

and I want to find the first row that has this id = 29c45630-7d41-11e9-8ea2-9f2bfe5760ab

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

when I run this code:

df[df['id'] == '29c45630-7d41-11e9-8ea2-9f2bfe5760ab']

return empty!!! and the type of this id is "object"

but I really have this id!!

how can I find it?

>Solution :

You code didn’t work because you have UUIDs, not strings, you first need to convert to string:

df[df['id'].astype(str).eq('29c45630-7d41-11e9-8ea2-9f2bfe5760ab')]

Output:

                                     id  hint
0  29c45630-7d41-11e9-8ea2-9f2bfe5760ab  None
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