Example df1
Abc Def GHI JKL
a 23 e h
b 24 g h
c 27 h k
d 34 f j
df2
Abc XYZ
a 23
b 24
c 27
d 34
e 54
f 32
g 21
I need output like this
Abc Def GHI JKL XYZ
a 23 e h 23
b 24 g h 24
c 27 h k 27
d 34 f j 34
df.merge
out = (df1.merge(df2, left_on='Def', right_on='Xyz')
.reindex(columns=['Abc', 'Def', 'Ghi', 'Jkl' , 'Xyz']))
print(out)
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.