Forgive me as I'm new to python, but I couldn't find any solution to this. I have a DF with a reoccurring Step Index and want to pull last data from Step 14, however this Index repeats. If Step == 14 & the next Step == 15, pull X, Y, Z from (last) Step 14.
Step X Y Z
12 3 7.001 4.015 2.917
12 3 7.001 4.100 3.966
13 3 4.633 4.100 4.439
13 3 0.984 4.100 5.491
13 3 0.898 4.100 5.538
14 3 -7.000 3.913 5.538
14 3 -7.000 3.858 5.538
14 3 -7.000 3.547 5.538
14 3 -7.000 3.523 5.538
15 4 0.000 3.523 5.538
15 4 0.000 3.523 5.538
12 4 7.001 3.809 0.583
12 4 7.001 4.100 4.029
13 4 4.633 4.100 4.502
13 4 0.980 4.100 5.553
13 4 0.910 4.100 5.592
14 4 -7.000 3.912 5.592
14 4 -7.000 3.546 5.592
14 4 -7.000 3.522 5.592
15 5 0.000 3.522 5.592
15 5 0.000 3.522 5.592
Output should be a new DF like this:
Step X Y Z
14 -7.000 3.523 5.538
14 -7.000 3.522 5.592
I'm guessing I will have to to an for statement with if/and to go through all columns to see if Step == 14 and next Step == 15.
Thank you,