Quantcast
Channel: How to remove rows from Pandas dataframe if the same row exists in another dataframe but end up with all columns from both df - Stack Overflow
Viewing all articles
Browse latest Browse all 3

How to remove rows from Pandas dataframe if the same row exists in another dataframe but end up with all columns from both df

$
0
0

I have two different Pandas data-frames that have one column in common. I have seen similar questions on Stack overflow but none that seem to end up with the columns from both dataframes so please read below before marking as duplicate.

Example:

dataframe 1

ID  col1 col2  ...1    9    52    8    43    7    3 4    6    2

dataframe 2

ID  col3  col4  ...3    11     154    12     167    13     17

What I want to achieve is a dataframe with columns from both dataframes but without the ID's found in dataframe2. i.e:

desired result:

ID  col1 col2  col3  col41    9    5     -     -2    8    4     -     -

Thanks!


Viewing all articles
Browse latest Browse all 3

Latest Images

Trending Articles





Latest Images

<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>
<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596344.js" async> </script>