df.groupby(['opponent']).game_id.nunique()= for index,group in df.groupby(df['opponent'])['game_id']: print(index) print(len(set(list(group))))