lookup and fill some value from one dataframe to another
I would recommend &quot;pivoting&quot; the first dataframe, then filtering for the IDs you actually care about.
Something like this:
useful_ids = [
    'A01',
    'A03',
    'A04',
    'A05',
]
df2 = df1.pivot(index='ID', columns='Mode')
df2 = df2.filter(items=useful_ids, axis='index')