Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR PYTHON

dataframe how to groupby apply list to multiple columns

df = df.groupby(['a','b']).apply(lambda x: [list(x['c']), list(x['d'])]).apply(pd.Series)
df.columns =['a','b','c','d']
Source by stackoverflow.com #
 
PREVIOUS NEXT
Tagged: #dataframe #groupby #apply #list #multiple #columns
ADD COMMENT
Topic
Name
4+8 =