Let's say we getting pandas index as input for a function. Then I need to get the next immediate index from the dataframe based on the index input. The dataframe index can be a string or number. I want to know how to do this.
For example:
index | col 1 |
---|---|
2342 | aaa |
2822 | bbb |
3452 | ccc |
If the function gets 2342 as input, how to get the immediate next index in the dataframe (2822)? Imagine that the dataframe usually has more than 100k rows. The indexing strategy is out of my control.