让我们合而为一
df.groupby(['ID','Name'],as_index=False).agg(lambda x : x.sum() if x.dtype=='float64' else ' '.join(x))Out[1510]: ID Name COMMENT1 COMMENT2 NUM0 1 dan hi you hello friend 3.01 2 jon dogcat 0.52 3 jon yeah yes nope no 3.1

让我们合而为一
df.groupby(['ID','Name'],as_index=False).agg(lambda x : x.sum() if x.dtype=='float64' else ' '.join(x))Out[1510]: ID Name COMMENT1 COMMENT2 NUM0 1 dan hi you hello friend 3.01 2 jon dogcat 0.52 3 jon yeah yes nope no 3.1