1>>> n_by_state = df.groupby("state")["state"].count()
2>>> n_by_state.head(10)
3state
4AK 16
5AL 206
6AR 117
7AS 2
8AZ 48
9CA 361
10CO 90
11CT 240
12DC 2
13DE 97
14Name: last_name, dtype: int64
15
1df['frequency'] = df['county'].map(df['county'].value_counts())
2
3 county frequency
41 N 5
52 N 5
63 C 1
74 N 5
85 S 1
96 N 5
107 N 5
11
1df.groupby(sepal_len_groups)['sepal length (cm)'].agg(count='count')
2
3sum_sep = sep.groupby('Year').agg({'TotalProjects':'sum',
4 'TotalFunds':'sum',
5 'TotalFunds':'count',
6 'SubDistrict':'count'})
7
8sum_sep.stb.subtotal(grand_label='Total').applymap('{:,.0f}'.format)