Not really sure exactly what is what you're doing, but here is something:
# Define dummy function (f)
def f(x):
# you can use here x.name, x.A, x.B
# >>> x.name
# 'paul'
# >>> x.A
# ['1', '2', '3']
# >>> X.B
# [1, 2, 3]
return x
>>> df1
ID A B
0 john * 1
1 paul 1 1
2 jones 1 1
>>> df2
ID A B
0 john # 2
1 paul 2 2
2 jones 2 2
>>> df3
ID A B
0 john @ 3
1 paul 3 3
2 jones 3 3
>>> pd.concat([df1,df2,df3]).groupby('ID').agg(list).apply(f, axis=1)
A B
ID
john [*, #, @] [1, 2, 3]
jones [1, 2, 3] [1, 2, 3]
paul [1, 2, 3] [1, 2, 3]
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…