0

I am comparing the performance of Eval,Query and ndarray and I need to draw a Line plot using the magic function timeit as shown below:

import pandas as pd

np.random.seed(125)
N = 100000
df = pd.DataFrame({'Arc':np.random.randint(10, size=N)})


print('===Vectorization with NumPy arrays===')
%timeit df[df.A.values > 5]

print("===Query===")
%timeit df.query('Arc > 10')


print("===Eval===")
%timeit df[df.eval('Arc > 10')]

Expected Graph:

source: google

enter image description here

min2bro
  • 4,509
  • 5
  • 29
  • 55
  • There are some examples using `perfplot` in my answer [here](https://stackoverflow.com/questions/54028199/for-loops-with-pandas-when-should-i-care). Take a look and implement it on your own. Let is know if you have trouble. – cs95 Jan 08 '19 at 09:59
  • @coldspeed Cool..Thank You!! – min2bro Jan 08 '19 at 10:05
  • Here you go: https://pastebin.com/7AbzcXgH – cs95 Jan 08 '19 at 10:10
  • I wasn't aware of perfplot. Just check it's documentation and it works like charm...In btwn I am writing a Blog where I am comparing performance of different pandas function and expressions and it seems you have lot of experience on that. Do you mind reviewing my blog before I publish? – min2bro Jan 08 '19 at 10:14
  • Sure, ping me when it is done and I can take a look. In the meantime, perhaps there is something [here](https://stackoverflow.com/questions/53779986/dynamic-expression-evaluation-in-pandas-using-pd-eval) that you may find useful. – cs95 Jan 08 '19 at 10:15
  • Not sure what are you talking about. I never down voted any of your answer yet. I am still digesting it.. – min2bro Jan 08 '19 at 10:24
  • Uff sorry, was not meant for you. – cs95 Jan 08 '19 at 10:24
  • @coldspeed Here is the link for the Blog, Your feedback much appreciated..https://colab.research.google.com/drive/1HDSD-4aos6Fbpg6sLCUlTzMJQ5ykLpFW – min2bro Jan 08 '19 at 10:32
  • It is asking for permission. Can you give me a sharable link that lets me view? – cs95 Jan 08 '19 at 10:35
  • @coldspeed Here is the gist link: https://gist.github.com/min2bro/f710819b4248d83e9b625c4f4166f1d0 – min2bro Jan 08 '19 at 10:38
  • Have added some comments under the gist. Good luck. – cs95 Jan 08 '19 at 10:45
  • Oh yes, also do consider upvoting my [query post](https://stackoverflow.com/questions/53779986/dynamic-expression-evaluation-in-pandas-using-pd-eval) if you found it helpful. TIA :) – cs95 Jan 08 '19 at 10:46
  • @coldspeed Sure, I will upvote. Do you mind if I take some points from your eval and query post for my Blog. I would give credit to you on the blog for this..Is it ok? – min2bro Jan 08 '19 at 10:48
  • By all means, please do so. – cs95 Jan 08 '19 at 10:48
  • Thanks..You are a Gem... – min2bro Jan 08 '19 at 10:49
  • Can I ask for your email id? so that I can share the blog link with you after I publish.. – min2bro Jan 08 '19 at 10:50
  • let me know if you didn't get that. – cs95 Jan 08 '19 at 10:50

0 Answers0