I have the following data:
Invoice NoStockCode Description Quantity CustomerID Country 536365 85123A WHITE HANGING HEART T-
IIUC
df.groupby(['Invoice','CustomerID'],as_index=False)['Description','NoStockCode'].agg(','.join) Out[47]: Invoice CustomerID Description \ 0 536365 17850 WHITEHANGINGHEARTT-LIGHTHOLDER,WHITEMETALANTER... NoStockCode 0 85123A,71053,84406B