擅长:python、mysql、java
<p>通过<code>collections.Counter</code>可以得到O(n)溶液:</p>
<pre><code>from collections import Counter
c = Counter(list(zip(df.Longitude, df.Latitude, df.Crime_type)))
</code></pre>
<p>结果:</p>
<pre><code>Counter({(-0.113767, 51.517372, 'Theft-from-the-person'): 1,
(-0.111497, 51.518226, 'Burglary'): 2,
(-0.111497, 51.518226, 'Other-theft'): 1,
(-0.106453, 51.518207, 'Bicycle-theft'): 1})
</code></pre>