0
$\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$
0
$\begingroup$
  1. You will want to load your data in two pandas dataframes (if you haven't already)
  2. Next you will want to use dataframe.join(): https://pandas.pydata.org/pandas-docs/stable/reference/api/pandas.DataFrame.join.html

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

$\endgroup$
  • $\begingroup$ Join is not working because I have duplicates in the column that is common to dataset A and B. $\endgroup$ – UZOCHUKWU URUAKPA 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$ – S van Balen Aug 15 '19 at 14:01

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.