How to lookup different dataframes and return the values?

Question:

Im trying to lookup the index in two different datframes and return the values.

For example, in df1 i would like to lookup in df2 and return the same index and values.

DF1 enter image description here

DF2 enter image description here

I would like my result to be like this.

RESULTS enter image description here

Asked By: Chris

||

Answers:

Get the IDs from df2 where the ID is in df1

filtered_df = df2[(df2['ID'].isin(df1['ID']))]

Try this

new_df = df2[df2.ID == [list(df1.ID)]]
Answered By: CharlieBONS
Categories: questions Tags: , , ,
Answers are sorted by their score. The answer accepted by the question owner as the best is marked with
at the top-right corner.