I have a data frame like this,

```
df
col1    col2
1        A
2        B
1        A
2        A
3        B
4        A
5        A
6        A
7        B
8        A
9        B

```

Now I want to filter this data frame and take all the rows till third B from the end, so the data frame will look like,

```
col1     col2
3        B -->third B
4        A
5        A
6        A
7        B -->second B
8        A
9        B -->first B

```

I could do this using a for loop check checking if its B in every iteration, but it will take longer time to execute, looking for some pandas shortcuts to do it in efficient way.