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

Subset of columns from another data frame

I have a dataframe (G) whose columns are “Client” and “TIV”.

I have another dataframe whose (B) columns are “Client”, “TIV”, “A”, “B”, “C”.

I want to select all rows from B whose clients are not in G. In other words, if there is a row in B whose Client also extsist in G then I want to delete it.

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

I did this:

x= B[B[‘Client’]!= G[‘Client’]

But it returned saying that “can only compare identically labeled Series Object”

I appriciate your help.

>Solution :

You can use df.isin combined with ~ operator:

B[~B.Client.isin(G.Client)]
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