0

I have a csv called 'data.csv' which has:

EmployeeIDNumber
A
B
C
D

I have another csv called 'basic.csv' which has the same data but is jumbled:

MemberIdentifier
B
A
C

I want to use PANDAS to create a result sheet which has:

EmployeeIDNumber MemberIdentifier
A                A
B                B
C                C
D                Not Found

1 Answers1

1

There are several ways to do this but the most powerful is the following,

import pandas as pd

df1 = pd.csv_read('data.csv')

df = merge(df1, df2, left_on='EmployeeIDNumber', right_on='MemberIdentifier', how='left')

Here we are choosing the specific columns we wish to join our DataFrames on. If you wish to also include any reading in the MemberIdentifier columns that does not match anything in the EmployeeIDNumber columns then you can set how='outer'.

Little Bobby Tables
  • 4,466
  • 4
  • 29
  • 46