title: Incorrect result when apply function to pandas Series
body: <p>When I tried to apply two versions of a function, pure python vs cython, to a pandas Series, two different results are obtained</p>
  
  <pre><code>import numpy as np
  import pandas as pd
  from libc.math cimport lround
  
  def py_func(n):
      return round(13 * n / 37)
  
  cdef int cy_func(int n):
      return lround(13 * n / 37)
  
  arr = np.arange(1000, 12000, 2000)
  
  series = pd.Series(arr)
  print("Original series:")
  print(series)
  
  series1 = series.apply(py_func)
  series2 = series.apply(cy_func)
  
  print("\nApplied with python function:")
  print(series1)
  
  print("\nApplied with cython function:")
  print(series2)
  </code></pre>
  
  <p>The results are</p>
  
  <pre class="lang-none prettyprint-override"><code>Original series:
  0     1000
  1     3000
  2     5000
  3     7000
  4     9000
  5    11000
  dtype: int32
  
  Applied with python function:
  0     351
  1    1054
  2    1757
  3     688
  4    1391
  5     322
  dtype: int64
  
  Applied with cython function:
  0     351
  1    1054
  2    1757
  3    2459
  4    3162
  5    3865
  dtype: int64
  </code></pre>
  
  <p>We can see that when applying the python function, we obtain incorrect results in the last three numbers. While the cython function yields the correct results.</p>
  
  <p>Why does the python function produce incorrect results? And how to fix it?</p>
  
  <p><strong>Update</strong></p>
  
  <p>The results above were obtained on Windows 10 64-bit. However, when I tried with Ubuntu 18.04 64-bit on the same machine (using WSL), both series have the correct results. In both cases, I have <code>Cython==0.29, numpy==1.15.2, pandas==0.23.4</code>, also tested with <code>Cython==0.28.5, numpy==1.14.5, pandas==0.23.3</code>.</p>
  
  <p>There's another difference in the results: with Windows 10, the <code>dtype</code> of the original series is <code>int32</code>, while the <code>dtype</code> on Ubuntu 18.04 is <code>int64</code>. The <code>dtype</code> of both result series are <code>int64</code> in both OS.</p>