我目前无法复制您的代码,但我认为:
print (df.groupby(['InvoiceNo','CustomerID','Country'], as_index=False)['NoStockCode','Description','Quantity'] .agg(lambda x: list(x)))
会给你预期的输出

我目前无法复制您的代码,但我认为:
print (df.groupby(['InvoiceNo','CustomerID','Country'], as_index=False)['NoStockCode','Description','Quantity'] .agg(lambda x: list(x)))
会给你预期的输出