@@ -50,7 +50,7 @@ We have a :class:`DataFrame` to which we want to apply a function row-wise.
5050 {
5151 " a" : np.random.randn(1000 ),
5252 " b" : np.random.randn(1000 ),
53- " N" : np.random.randint(100 , 1000 , (1000 )),
53+ " N" : np.random.randint(100 , 1000 , (1000 ), dtype = " int64 " ),
5454 " x" : " x" ,
5555 }
5656 )
@@ -83,7 +83,7 @@ using the `prun ipython magic function <https://ipython.readthedocs.io/en/stable
8383.. ipython :: python
8484
8585 # most time consuming 4 calls
86- % prun - l 4 df.apply(lambda x : integrate_f(x[" a " ], x[" b " ], x[" N " ]), axis = 1 ) # noqa E999
86+ % prun - l 4 df.apply(lambda x : integrate_f(x[' a ' ], x[' b ' ], x[' N ' ]), axis = 1 )
8787
8888 By far the majority of time is spend inside either ``integrate_f `` or ``f ``,
8989hence we'll concentrate our efforts cythonizing these two functions.
@@ -164,7 +164,7 @@ can be improved by passing an ``np.ndarray``.
164164
165165.. ipython :: python
166166
167- % prun - l 4 df.apply(lambda x : integrate_f_typed(x[" a " ], x[" b " ], x[" N " ]), axis = 1 )
167+ % prun - l 4 df.apply(lambda x : integrate_f_typed(x[' a ' ], x[' b ' ], x[' N ' ]), axis = 1 )
168168
169169 .. ipython ::
170170
@@ -204,7 +204,7 @@ calls are needed to utilize this function.
204204
205205.. ipython :: python
206206
207- % timeit apply_integrate_f(df[" a " ].to_numpy(), df[" b " ].to_numpy(), df[" N " ].to_numpy())
207+ % timeit apply_integrate_f(df[' a ' ].to_numpy(), df[' b ' ].to_numpy(), df[' N ' ].to_numpy())
208208
209209 Performance has improved from the prior implementation by almost ten times.
210210
@@ -218,7 +218,7 @@ and ``wraparound`` checks can yield more performance.
218218
219219.. ipython :: python
220220
221- % prun - l 4 apply_integrate_f(df[" a " ].to_numpy(), df[" b " ].to_numpy(), df[" N " ].to_numpy())
221+ % prun - l 4 apply_integrate_f(df[' a ' ].to_numpy(), df[' b ' ].to_numpy(), df[' N ' ].to_numpy())
222222
223223 .. ipython ::
224224
@@ -253,7 +253,7 @@ and ``wraparound`` checks can yield more performance.
253253
254254.. ipython :: python
255255
256- % timeit apply_integrate_f_wrap(df[" a " ].to_numpy(), df[" b " ].to_numpy(), df[" N " ].to_numpy())
256+ % timeit apply_integrate_f_wrap(df[' a ' ].to_numpy(), df[' b ' ].to_numpy(), df[' N ' ].to_numpy())
257257
258258 However, a loop indexer ``i `` accessing an invalid location in an array would cause a segfault because memory access isn't checked.
259259For more about ``boundscheck `` and ``wraparound ``, see the Cython docs on
0 commit comments