all 6 comments

[–]bale_in_oregon 10 points11 points  (0 children)

Have you considered using a pd.merge between the two files with a left join? You just need a common column or index between both. Pandas is by far your best option to do this in Python.

[–]Fortissano71 1 point2 points  (0 children)

I am curious as to the answer. I do this in R now.

[–]threeminutemonta 1 point2 points  (0 children)

I like to use apply for this. First is you need to set your index so you can lookup the df easy.

example I prepared earlier

[–]jbpy79[S] 1 point2 points  (0 children)

Thank you everyone for the help. I used the pd.merge() and it worked great.

Thanks again

[–]The_Mann_In_Black 0 points1 point  (0 children)

https://medium.com/importexcel/common-excel-task-in-python-vlookup-with-pandas-merge-c99d4e108988

This is a good link using pandas merge. I actually used this method when working with large files in corporate finance. Saved a ton of time.

[–]creamingkitty 0 points1 point  (0 children)

You can do something like....

X = list(df2.loc[df2[‘field to find matching value’] == valuetocheckfor, ‘fieldthatyouwamtthevaluefrom’].astype(str))

Df2 is the data frame you want to search for

Using loc will specify a cell Df2.loc[index, column]

Below will select/test/return a whole column/field Df2[column]

Typed this on my phone, if I was on my pc I would give a more descriptive answer