Scenario:
- df1 has all possible auction ID values
- df2 has a subset of possible auction ID values
- df2 contains the object ID present in the auction (can be 0 or positive int)
Goal:
Create a new df1 column "object_id" populated with corresponding values in df2
Example...
df1 = pd.DataFrame(columns=['auction_id'], data=[1,2,3,4,5,6,7,8,9])
auction_id
1
2
3
4
5
6
7
8
9
df2 = pd.DataFrame({'auction_id':[1,2,4,6,7,8,9], 'object_id': [640,0,332,332,0,58,332]})
auction_id object_id
1 640
2 0
4 332
6 332
7 0
8 58
9 332
My best effort so far
using vlookup in Pandas using join):
df1['object_id'] = df1.auction_id.map(df2.object_id)
Which yields:
df1
auction_id object_id
1 0
2 332
3 332
4 0
5 58
6 332
7 NaN
8 NaN
9 NaN