Skip to content

Commit 3db3d2c

Browse files
committed
remove E999 and put int64 in creation of df
1 parent 24d09f5 commit 3db3d2c

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

doc/source/user_guide/enhancingperf.rst

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -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``,
8989
hence we'll concentrate our efforts cythonizing these two functions.
@@ -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'].astype(int).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'].astype(int).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'].astype(int).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.
259259
For more about ``boundscheck`` and ``wraparound``, see the Cython docs on

0 commit comments

Comments
 (0)