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

Pandas equivalent of R merge all=TRUE

apologies if this sounds like a dumb question, I haven’t worked on Pandas for a long time.

I’ve two data frames, Nodes:

Nodes

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

Rate Card:

Rate Card

I want the final output to look like this, total would be 7*10= 70 rows:

OP

In R, I use the following piece of code to do this:

prem_subset = merge(nodes, subset(rate_card, select=c("service", "duration","rate")),all=TRUE)

where I'm only selecting some columns from my original rate_card df

I can’t find the Pandas equivalent for this.

>Solution :

IIUC I believe you are looking for pandas merge with option how=cross:

select_cols = ['service', 'duration', 'rate']
nodes.merge(rate_card[select_cols], how='cross')
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