groupby and list

Solutions on MaxInterview for groupby and list by the best coders in the world

showing results for - "groupby and list"
Frieda
19 May 2018
1In [1]: df = pd.DataFrame( {'a':['A','A','B','B','B','C'], 'b':[1,2,5,5,4,6]})
2        df
3
4Out[1]: 
5   a  b
60  A  1
71  A  2
82  B  5
93  B  5
104  B  4
115  C  6
12
13In [2]: df.groupby('a')['b'].apply(list)
14Out[2]: 
15a
16A       [1, 2]
17B    [5, 5, 4]
18C          [6]
19Name: b, dtype: object
20
21In [3]: df1 = df.groupby('a')['b'].apply(list).reset_index(name='new')
22        df1
23Out[3]: 
24   a        new
250  A     [1, 2]
261  B  [5, 5, 4]
272  C        [6]
28
Glynis
03 Oct 2016
1values = set(map(lambda x:x[1], mylist))
2newlist = [[y[0] for y in mylist if y[1]==x] for x in values]
3
queries leading to this page
groupby methodspython grouperpython group list elementshow to list a column in pandas group ygroup by phythongroup by 28 29 python group 28 29 pythongroupby to list pandasgroupby a column pandasfunction group by in pythongroup function in pythongroupby function python groupby python group in pythondf groupbygroupby package in python with examplegroupby org pythongroup by functions in pythongroup by in python groupby 28 29group items in list pythongroup function python what does groupby 28 29 returngroup 28 29 pythonpython df groupbygroupby operationshow to groupby a column and get the group as list of listgroupby by function in pytohnpython list group by funcitongroup by i pythingroup by in pythongroup list object pythonuse group by pythongroupby get listpython list groupgroupby functions in pythongroup method in python group by pyhtondf groupby 28 29 what it returnswhat does group by does in pythongroup by list groupby value in list pythongroupby pandas examplepandas groupby list of listshow to group a list in pythongroup pythongroup by function pythongroupby and form list pandasgroupby dataframe pythongroupby a column in pandasdataframe groupby examplegroup by and collect list pandasgroupby in python stringgroupby 28 29group in listgroupby in python listgroup a list in pythongroupby dataframe in pythongroup by in pytolist groupbyfunction group by and to listdataframe groupbylist item group by pythonpython groupby columnpython groupby describegroupby dataframegroup by python dataframepython group items in listhow to use groupby all in pythongroupby and column to listpython group functions in pythonwhat is the groupbykry in python 3ffunctions in groupby pythongroupby and listpython groupby list valuesgroup by in python examplepandas groupby a column and list group method pythongroupby in pythongroupby pandas listgroupby function in pythongroup pythonhow to use group by in pythongroupby function explainedgroupby python3group by in pytho df groupby 28 29pandas groupbypandas groupby in a groupbyhow to use groupby function in pythongroup elements in listwhere and groupbygroup by in to listgroupby pandasthe groupby functionusing groupby in pandas groupby 28get group list by group pandasgroup list elements pythongroupby methods completegroup by in python pandasdf groupby in pythongroupby lists in pandaspython groupby grouperlist group by pythongroup by to listhow to use group by in python 3fhow to use groupby in pythongroup a list pythonusing groupbygroup data in list pythongroupby function dataframelist grouper pythonpython group 28 29pandas groupby bygroupby in python pandasall groupby functions pythonuse groupby pandasgroup method on pythonpandas groupbyxgroupby and orderby examplegroup list pythongroup list in dataframe pythonlist group bypython groupby filtergroupby attribute in pythongroupby functions pythongroup by in python codepython pandas groupby listpython group by value listgroupby python listpython group list valuesgroup by function in python pandasgroupby command pandaswhy is groupby 28 29 operation usedgroup elements in list pythongroupby to show list of valuesgroupby to dataframegroupby python stringdata list groupbypandas groupby function groupby in pandasgroupby methods pandaspython groupby to listwhat does groupby do in pandaspython groupgroup list object pythonpython groupby list of listsgroupby by functionhow to groupby in pythonpython group 28 29group by python listgroupby python examplewhat is groupby in pandasgroup by value pythongroup listgroup by python limitedre python groupgroup by in python listpython group 28 29 methoddataframe groupby listgroup by as listgroupby value from list in pandasgroup by list pandas examplepandas groupby categorygroupby list pythongroup by values in list python group method in pythongroupe by pythongroup using function whole listgroupby syntax pythongroupby function in pandaspython groupby examplegroup 281 29 pythongroupby get dataframepython group list elements by valuegroupby in pandasgroupby pandas on listgroupby function for lists in pythongroup by list python how to group a listgroupby with wheregroupby based on a column pandasgroup array by value pythonpython group 281 29groupby accompanied functions pythongroup by a listgroup by pythongroup by value in list pythondf groupbygroup by to dataframecan we use group by in listpandas groupby explainedgroup by in a list pythongroup python listgroupby python dataframegroupby into listwhen we use groupby in pythonpython group by listfunction groupby pythongroupby then chart pythonpython do a group by on listgroupby in python and create a list of groupbygroup by in graphene pythonpandas group by list contentspython groupby functionpython group bylist group item functiongroup by list item in pythonpython group list of listusing groupby pandaspython list group bygroup by pytohngroupby pandas pythondf groupby pythongroupby in python 3groupby to listgroupby values to listselect group of list pythonpython group list by value group by in pythonpython group listgroupby and order by pythongroup by function in pythonpython group list elements by twopython group value listgroup by to dataframe with listpandas groupby columngroupby pandasgroupby into list pythongroup by in pandagroup list items pythonpython group functiongrouping in list pythonpython group methodgroupby to list pythongiven a list group by a valuepython groupby 28 29 group a list in npythongroup in list pythongroupyby in pandasgroupby all dfpython list group bygrouping value from list in pandasgroup in pythonpython groupbygroup by function in pandaspython list group by 3groupby real pythongroupby with and clause pythongroupby and wheregroup by python examplegroupby wheregroupby list pandasgroupby listgroup by to list pandashow to do groupby in python using a functiongroupby examplegroupby documentationpython functions for groupbygroupby functionpy list make group bywhat does groupby 28 29 5b 5d doeshow to use groupby in pandaspandas groupby list groupby 28 29 pythongroup by with list dataframehow may group a list in pythonphython group bypandas groupby column and groupergroupby pdgroup 281 29 in pythongroupby pythongroup 28 29 in pythonimplement a groupby fun in pythongroupby and list