парные комбинации Groupby

from itertools import combinations
ndf = df.groupby('ID')['words'].apply(lambda x : list(combinations(x.values,2)))
                          .apply(pd.Series).stack().reset_index(level=0,name='words')
# groupby ids and get all possible  pairwise combinations of words 
Real Raccoon