python: cumulative concatenate in pandas dataframe
问题 How to do a cumulative concatenate in pandas dataframe? I found there are a number of solutions in R, but can't find it in python. Here is the problem: suppose we have a dataframe: with columns: date and name : import pandas as pd d = {'date': [1,1,2,2,3,3,3,4,4,4], 'name':['A','B','A','C','A','B','B','A','B','C']} df = pd.DataFrame(data=d) I want to get CUM_CONCAT , which is a cumulative concatenate groupby date: date name CUM_CONCAT 0 1 A [A] 1 1 B [A,B] 2 2 A [A] 3 2 C [A,C] 4 3 A [A] 5 3