공부
[python][pandas] df.groupby('a').agg({'b':lambda x: list(x)})
승가비
2022. 8. 6. 06:48
728x90
df.groupby('a').agg({'b':lambda x: list(x)})
https://stackoverflow.com/questions/22219004/how-to-group-dataframe-rows-into-list-in-pandas-groupby
How to group dataframe rows into list in pandas groupby
I have a pandas data frame df like: a b A 1 A 2 B 5 B 5 B 4 C 6 I want to group by the first column and get second column as lists in rows: A [1,2] B [5,5,4] C [6] Is it possible to do somethin...
stackoverflow.com
728x90