I have following dataframe:
name gender count
0 A M 3
1 A F 2
2 A Nan 3
3 B NaN 2
4 C F 4
5 D M 5
6 D Nan 5
I would like to build a resulting dataframe df1 which deletes that last row of group of name attribute if the count of that group is greater than 1. For eq- name A is present 3 times, hence the last row containing A should be removed. B and C are only present once, hence the rows containing them should be retained.
Resulting dataframe df1 should be like this:
name gender count
0 A M 3
1 A F 2
2 B NaN 2
3 C F 4
4 D M 5
Please advice.