List of Contributions

Kaustuv Chakraborti

Contact Details

My Content

1 to 1 of 1 total
Posted By Kaustuv Chakraborti Thu November 12, 2020 11:30 AM
Found In Egroup: Global AI and Data Science
\ view thread
Hi, The below code snippet should work you . import pandas as pd df = pd.DataFrame([['A',3],['A',6],['A',5],['B',8],['B',8],['B',6],['B',4],['C',5],['C',6],['C',7]],columns=['col1','col2']) new_df = df.set_index('col1').groupby(['col1'])['col2'].apply(list).reset_index('col1') final_df = ...