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

.isin() returning a blank dataframe

My DataFrame:

My Dataframe

Trying…

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

Does not work

Nope…

Does not work

Still nope…

AND YET…

Huh?

Any idea why I can’t filter this dataframe by a list using isin?

I’m expecting it to return one or more rows where the Chord Notes column equals the list [‘C’,’E’,’G’]

>Solution :

you can still use isin() but since the values under ‘Chord Notes’ are actual list object so you have to pass that list object i.e ['C','E','G'] in isin() method

output = full_chords[full_chords['Chord Notes'].isin([['C','E','G']])]

Or with map() (kind of loop under the hood):

output = full_chords[full_chords['Chord Notes'].map(lambda x:x==['C','E','G'])]

Or

Other way around is to typecast that column to string(not recommended but still an option tho):

output = full_chords[full_chords['Chord Notes'].astype(str).eq("['C','E','G']")]
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