1
$\begingroup$

I have a dataset A and dataset B, both data has a column in common which is the ID, i want to check if dataset A ID values can be found in dataset B ID values. Also get the records of dataset B that have the same value with dataset A. I can do this on excel using vlookup, but I want to automate the process using python.

NOTE: 1. dataset B has 10020 rows while dataset A has 2039 rows. 2. The ID column is numeric.

Thanks.

$\endgroup$
1
  • $\begingroup$ If the ID column is duplicated in B but unique in A, I think it is ok, right? because you want to get all rows in B that belong to the same row in A. $\endgroup$
    – user119783
    Jun 30 at 13:11
0
$\begingroup$
  1. You will want to load your data in two pandas data frames (if you haven't already)
  2. Next you will need to use dataframe.join():

Note: You might want to think about the mode (inner, outer, left or right)

$\endgroup$
3
  • $\begingroup$ Join is not working because I have duplicates in the column that is common to dataset A and B. $\endgroup$ Aug 15 '19 at 13:58
  • $\begingroup$ Checking: in both datasets there is a column id, and in neither of which it is unique? $\endgroup$ Aug 15 '19 at 14:01
  • $\begingroup$ Do you have duplication in the ID column in both tables? $\endgroup$
    – user119783
    Jun 30 at 13:14

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.