I have a dataframe that I am trying to limit to 3 occurrences of a unique value. My table is like this:
A B C
1  a  a
1  b  c
1  b  a
1  c  a
2  c  a
2  a  b
2  e  f
3  e  a  
And I want to filter on column A. The resultant table would be
A B C
1  a  a
1  b  c
1  b  a
2  c  a
2  a  b
2  e  f
3  e  a  
I have the code working in a iterrows() loop right now, but it is a bit slow, so I was wondering if there was a better way to do this.
