如何使用类似于vlookup pandas的功能

时间:2017-12-04 09:17:52

标签: python python-3.x pandas

如何在pandas中使用与vlookup类似的功能。

df 1:

       AS     G    DA     VV     VV
0  potato    this  is   spart  today
1  potato  surely  not    the    day
2     you  retire  is      it    day

df 2:

        V     V     VA      ZD     VE
0       a  does  potato    even   work
1       I    am  potato    even  today
2       O   how  potato  mighty   have
3  fallen     O  potato       K      R

数据框我希望:

        V     V     VA      ZD     VE
0       a  does  potato    even   work
1       I    am  potato       even  today
2       O   how  NaN      mighty   have
3  fallen     O  NaN       K      R

我试过了 -

df1.insert(2, 'VA', df1['AS'].map(df2.set_index('AS')['VA']))
#KeyError#####

0 个答案:

没有答案