擅长:python、mysql、java
<p>假设<code>entities</code>中的元素是<code>list</code>:</p>
<pre><code>df.groupby(['industry', 'index'])['entities'].apply(lambda x: [l for l in x]).reset_index()
</code></pre>
<p>输出:</p>
<pre><code> industry index entities
0 cars 0 [[Norway, it], [Mercedes, they], [it, EV, its]]
1 nature 1 [[fox, it], [them, rabbits]]
2 nature 2 [[whale, it]]
</code></pre>