Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR PYTHON

pandas groupby to get list of values

groupByCol = "FID"
elementFromColToList = "name_ID"

temp = df.groupby(groupByCol)[elementFromColToList].apply(list).to_frame()
temp
                  
groupid      b      
1            [1, 2, 3]
3            [27]
4            [42, 42, 8]
Source by medium.com #
 
PREVIOUS NEXT
Tagged: #pandas #groupby #list #values
ADD COMMENT
Topic
Name
5+3 =