擅长:python、mysql、java
<p>我认为第<code>ip</code>列中的第一个值是唯一的,就像我的第一行和第二行一样——那么在<code>groupby</code>之后的<code>domain</code>列中只有一个值:</p>
<pre><code>print pDNSPanda
ip domain
0 0.0.0.0 ip|domain
1 1.1.1.200 ip|domain
2 46.101.214.145 cnwkabrnyld1c0[.]com
3 46.101.214.145 anfj63m[.]com
4 46.101.214.145 anf3xnem[.]com
5 69.195.129.70 cnwkabrnyld1c0[.]com
6 69.195.129.70 anfj63ms[.]com
g = pDNSPanda.groupby("ip").agg('|'.join)
print g
domain
ip
0.0.0.0 ip|domain
1.1.1.200 ip|domain
46.101.214.145 cnwkabrnyld1c0[.]com|anfj63m[.]com|anf3xnem[.]com
69.195.129.70 cnwkabrnyld1c0[.]com|anfj63ms[.]com
</code></pre>
<p>但我认为最好是将<code>groupby</code>与aggregate column一起使用,正如他在回答中提到的<code>Alexander</code>。在</p>