I have a pandas data frame df like:
df
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 col
Let us using df.groupby with list and Series constructor
df.groupby
Series
pd.Series({x : y.b.tolist() for x , y in df.groupby('a')}) Out[664]: A [1, 2] B [5, 5, 4] C [6] dtype: object