@sasidharp can you provide a little more details? Are you running your Python code as part of a Python Code Recipe? Or a scenario script? Or other?
As far as I am aware, if your data (in a Pandas dataframe) is not sorted on date adn you create a datetime index from some date field/fields, you will indeed have a datetime index, but not necessarily in any order. If the data is small enough to fit in memory in DSS you can run the following to sort (before processing):
data_frame = data_frame.sort_index()
Alternatively, you could probably use a different recipe or logic to ensure that the input dataset is correctly sorted to begin with.
@sasidharp, Let me know if this is obvious to you and I missed some other detail that can help me provide better guidance. Hope this helps.