Why does %timeit loop different number of times?

后端 未结 3 1780
你的背包
你的背包 2021-02-18 22:12

On Jupter Notebook, i was trying to compare time taken between the two methods for finding the index with max value.

In the Image, the first function took, 1000

3条回答
  •  忘掉有多难
    2021-02-18 22:36

    %timeit library will limit the number of runs depending on how long the script takes to execute.

    The number of runs may be set with -n. Example:

    %timeit -n 5000
    df = pd.DataFrame({'High':[1,4,8,4,0]})
    
    5000 loops, best of 3: 592 µs per loop
    

提交回复
热议问题