Table A :
y type
1 a
1 a
0 b
1 c
0 b
1 a
------------
Table B
type x
a 0.1
b 0.2
c 0.3
------------
I want to replace A.type with corresponding x in B. Thus the result I want is:
y type
1 0.1
1 0.1
0 0.2
1 0.3
Use pd.Series.map
A['type'] = A.type.map(B.set_index('type').x)
y type
0 1 0.1
1 1 0.1
2 0 0.2
3 1 0.3
4 0 0.2
5 1 0.1