I am trying to filter a dataset in Pandas. The number must always increase, although this can be in irregular steps. I have set up a filter to ensure any values that are smaller than their predecessor are removed from the DataFrame. This is a simple example I am working with:
test = {"Test": [1, 3, 5, 7, 9, 2, 11, 4, 13]}
df = pd.DataFrame(test)
df = df[df.Test.shift() + 1 < df.Test]
This works, with the exception that it is also dropping 0 index. i.e. the output:
Test
1 3
2 5
3 7
4 9
6 11
8 13
is missing row 0 1
Any ideas how to get this row in as well?