Pandas, filter by count

I’m trying to filter a dataframe by the number of occurrences for id.

id    date
1     2018-05-06
1     2018-05-08
1     2018-05-11
2     2018-06-02
2     2018-06-16
3     2018-06-04
3     2018-06-09
4     2018-06-06
4     2018-06-11
4     2018-06-17

I want to filter for the id values that have 3 occurrences, so the resulting filtered dataframe should look like this:

id    date
1     2018-05-06
1     2018-05-08
1     2018-05-11
4     2018-06-06
4     2018-06-11
4     2018-06-17

I previously had tried using the following code, which actually worked at one point. When I used it about a half hour later, it gave me the error “lambda cannot contain assignment”:

graphview3 = df.groupby('id').filter(lambda x: x['id'].count()=3)

I don’t know why this code previously worked and is now giving me this error. Any help on this?

Maybe you turned == (equality check) into = (assignment)

That was stupid of me. Forgot that it was a Boolean. Thanks!