Q:

Count duplicate rows for each unique row value

I have the following pandas DataFrame:
a  b  c
1  s  5
1  w  5
2  s  5
3  s  6
3  e  6
3  e  5

I need to count duplicate rows for each unique value of a to obtain the following result:
a  qty
1  2
2  1
3  3

How to do this in python? 

A:

You can use groupby:
g = df.groupby('a').size()

This returns:
a
1    2
2    1
3    3
dtype: int64

EDIT: rename only the single new column of counts. 
If you need a new column you can:
g  = df1.groupby('a').size().reset_index().rename(columns={0:'qty'})

to obtain:
   a  qty
0  1    2
1  2    1
2  3    3

