擅长:python、mysql、java
<pre><code>d1 = df.groupby('id', as_index=False).agg(lambda x: x.tolist())
d1.assign(v2count=d1.v2.str.len(), firstv2=d1.v2.str[:1])
id v2 value firstv2 v2count
0 1 [100, 2] [10, 20] [100] 2
1 2 [200] [20] [200] 1
2 3 [300, 3] [30, 60] [300] 2
3 4 [400, 4] [40, 6] [400] 2
4 5 [1] [10] [1] 1
5 7 [5] [2] [5] 1
</code></pre>