Skip to content
Advertisement

I want to select data from different df, how can I speed it up?

I want to take the last data before the specified time from different time intervals df, my code is as follows:

JavaScript

On my computer, the running time of get_result_df() is 204ms, how can I speed up the running speed of get_result_df()?

JavaScript

I optimized it, and the running time was reduced to 53ms. Is there any room for improvement?

JavaScript
JavaScript

Answers to my questions on code view SE:

JavaScript

Advertisement

Answer

My times are roughly halved, but I see the same behavior. Faster using argmin from np. See below.

JavaScript

Argmin + iloc directly it is faster:

JavaScript
User contributions licensed under: CC BY-SA
9 People found this is helpful
Advertisement