擅长:python、mysql、java
<p>可以将<code>groupby</code>与函数<a href="http://pandas.pydata.org/pandas-docs/stable/generated/pandas.DataFrame.size.html" rel="noreferrer">size</a>一起使用。
然后我用重命名列<code>0</code>将索引重置为<code>count</code>。</p>
<pre><code>print df
Month LSOA code Longitude Latitude Crime type
0 2015-01 E01000916 -0.106453 51.518207 Bicycle theft
1 2015-01 E01000914 -0.111497 51.518226 Burglary
2 2015-01 E01000914 -0.111497 51.518226 Burglary
3 2015-01 E01000914 -0.111497 51.518226 Other theft
4 2015-01 E01000914 -0.113767 51.517372 Theft from the person
df = df.groupby(['Longitude', 'Latitude', 'Crime type']).size().reset_index(name='count')
print df
Longitude Latitude Crime type count
0 -0.113767 51.517372 Theft from the person 1
1 -0.111497 51.518226 Burglary 2
2 -0.111497 51.518226 Other theft 1
3 -0.106453 51.518207 Bicycle theft 1
print df['count']
0 1
1 2
2 1
3 1
Name: count, dtype: int64
</code></pre>