Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR PYTHON

pairwise combinations 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 
Source by stackoverflow.com #
 
PREVIOUS NEXT
Tagged: #pairwise #combinations #groupby
ADD COMMENT
Topic
Name
9+7 =