Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR PYTHON

pandas groupby values in list

pd.DataFrame( {'a':['A','A','B','B','B','C'], 'b':[1,2,5,5,4,6]})
df.groupby('a')['b'].apply(list)

Out: 
a
A       [1, 2]
B    [5, 5, 4]
C          [6]
Name: b, dtype: object
Source by stackoverflow.com #
 
PREVIOUS NEXT
Tagged: #pandas #groupby #values #list
ADD COMMENT
Topic
Name
9+5 =