From the course: Faster pandas

Unlock the full course today

Join today to access over 22,600 courses taught by industry experts or purchase this course individually.

Solution: Cython speedup

Solution: Cython speedup

From the course: Faster pandas

Start my 1-month free trial

Solution: Cython speedup

(upbeat music) - [Instructor] Start ipython. Then we're going to import pandas as pd, and S equal PD.series(range(1_000_000)) And now we're going to run second.py to load the code. And we can timeit. So timeit second of s, that's 260 milliseconds. And now let's use the cython version. So load, load the ext of cython. And then we can use the cython magic. I'm going to paste the function code and just rename it, call it cy-second, and Enter. And let's see cy-second of s equal to second of s. And we see they have the same functionality. And now we can do timeit cy-second office, and that's 207 milliseconds. So 260 divided by 207, we have about 25% speed up.

Contents