Skip to content Skip to sidebar Skip to footer

Excel Vlookup Equivalent In Pandas

I have following dataframe: A B C Index 2001-06-30 100 2001-08-31 (=value of A at date B) 2001-07-31 200 2001-09-30

Solution 1:

I think you need map by column A:

df['C']=df.B.map(df.A)print(df)ABCIndex2001-06-30  1002001-08-31  300.02001-07-31  2002001-09-30  400.02001-08-31  3002001-10-31    NaN2001-09-30  4002001-11-30    NaN

It is same as:

df['C']=df.B.map(df.A.to_dict())print(df)ABCIndex2001-06-30  1002001-08-31  300.02001-07-31  2002001-09-30  400.02001-08-31  3002001-10-31    NaN2001-09-30  4002001-11-30    NaN

Post a Comment for "Excel Vlookup Equivalent In Pandas"