```
import pandas as pd
import numpy as np
won_last = pd.DataFrame({'lastwin':["lastwin_{}".format(i) for i in range(10000)]})
dset = pd.DataFrame(np.random.randint(10000, size=(10000, 2)),
columns=['home', 'visitor'])
In [2]:
%timeit dset.merge(won_last, left_on='home', right_index=True,how='left').merge(won_last, left_on='visitor', right_index=True,how='left', suffixes="hv")
7.16 ms ± 340 µs per loop (mean ± std. dev. of 7 runs, 100 loops each)
In [3]:
%timeit dset.assign(hlastwin=lambda x: [won_last.lastwin[ii] for ii in x.home], vlastwin=lambda x: [won_last.lastwin[ii] for ii in x.visitor])
355 ms ± 34.9 ms per loop (mean ± std. dev. of 7 runs, 1 loop each)
```