return matches[0] if len(matches) > 0 else np.nan
df['GameName'] = df['user-agent'].apply(get_keyword)
df['GameName'] = df['GameName'].map(mapping)
Python Pandas: Lookup table by searching for substring