I have a Pandas DataFrame, called Matches with a column called MatchIDs. This contains a selection of Match IDs as below:
Matches
MatchIDs
Man CityTotte
Use isin for check values of column MatchIDs in second df called Rivals, last cast boolean mask to int by astype:
df
Rivals
int
Matches['new'] = Matches['MatchIDs'].isin(Rivals['MatchIDs']).astype(int)
Also if values are in list:
list
Matches['new'] = Matches['MatchIDs'].isin(L).astype(int)