I have a dataframe like this. I want to pick the rows above if a certain condition is met. For example here if number > 2, then i want to pick the rows with John, richard and paul. i.e the rows with numbers that led up to three. I also want to pick the 5 rows above myers. i.e myers, Jessica, Ashton, Whiley, Jason.
name number
Adrian 1
Peter 2
John 1
Richard 2
Paul 3
Ashley 1
Winchester 0
Jason 1
Whiley 2
Ashton 3
Jessica 4
myers 5
The output could look like this
name number
John 1
Richard 2
Paul 3
Jason 1
Whiley 2
Ashton 3
Jessica 4
myers 5