I have a dataset:
id value
a1 14
a1 2
a1 34
a1 11
a1 78
b1 11
b1 9
b1 6
I want to filter that dataset by number if rows for each group, to make it no higher than 4. So desired output will be:
id value
a1 14
a1 2
a1 34
a1 11
b1 11
b1 9
b1 6
How to do that?