I am dealing with a pandas data frame as shown below.
id x1 y1
0 2 some_val some_val
1 2 some_val some_val
2 2 some_val some_val
3 2 some_val some_val
4 2 some_val some_val
5 0 0 0
6 3 some_val some_val
7 3 some_val some_val
8 0 0 0
9 5 some_val some_val
10 5 some_val some_val
11 5 some_val some_val
12 0 0 0
13 6 some_val some_val
14 6 some_val some_val
15 6 some_val some_val
16 6 some_val some_val
My original data frame was the data frame without the rows with all '0' values. As per the project requirement I had to insert the rows with all 0's value whenever the "id" changes.
Now I want to delete all the rows of any "id" which has 3 and less than 3 rows. From the above data frame, I would want to delete all the respective rows of id- "3" and "5" . My resultant data frame should look like below:
id x1 y1
0 2 some_val some_val
1 2 some_val some_val
2 2 some_val some_val
3 2 some_val some_val
4 2 some_val some_val
5 0 0 0
6 6 some_val some_val
7 6 some_val some_val
8 6 some_val some_val
9 6 some_val some_val
Kindly suggest me a way to obtain this result.