Skip to content

How to speedup schedule[X:Y] lookup #259

Answered by ValueRaider
ValueRaider asked this question in Q&A
Discussion options

You must be logged in to vote

nanos only gave me a 20% boost, but I appreciate that's probably the best without moving to SQL. I ended up caching the query results for decent speedup.

The nanos code in case anyone else is interested. Use numpy's searchsorted() not pandas

cal.schedule["idx_nanos"] = cal.schedule.index.values.astype("int64")
...
slc_start = cal.schedule["idx_nanos"].to_numpy().searchsorted(start_ts.value, side="left")
slc_end = cal.schedule["idx_nanos"].to_numpy().searchsorted(end_ts.value, side="right")
sched = s[slc_start:slc_end]

So probably not worth adding those access methods.

Replies: 4 comments

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Answer selected by gerrymanoim
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
3 participants