title: apply a custom numba njit function to pandas rolling object
body: <p>With the <code>pandas</code> 1.0.0 release, <code>.apply</code> now has the <a href="https://pandas.pydata.org/pandas-docs/stable/user_guide/enhancingperf.html#using-numba" rel="nofollow noreferrer">ability</a> to use <code>numba jit</code> functions.</p>
  
  <p>Is there a way to take advantage of this <code>.apply</code> functionality when using <code>.rolling</code> ?</p>
  
  <p>For example I have a <code>pandas.DataFrame</code>, and a <code>numba_mean</code> function I would like to apply to get a rolling mean of 3 periods.</p>
  
  <pre><code>import pandas as pd
  import numpy as np
  import numba as nb
  
  df = pd.DataFrame({"A" : np.random.rand(10)})
  @nb.jit 
  def numba_mean(x): 
      return np.sum(x) / len(x) 
  
  df.A.rolling(3).apply(numba_mean)
  </code></pre>
  
  <p>However I get the below error, which means it does not work with <code>nopython</code> mode.</p>
  
  <blockquote>
    <p>Compilation is falling back to object mode WITH looplifting enabled because Function "numba_mean" failed type inference due to: non-precise type pyobject</p>
  </blockquote>
  
  <p>The Error traceback when applying <code>numba_mean</code> with <code>njit</code> rather than <code>jit</code></p>
  
  <blockquote>
    <p>This error may have been caused by the following argument(s):
    - argument 0: cannot determine Numba type of <code>&lt;class 'pandas.core.series.Series'&gt;</code></p>
  </blockquote>
  
  <p>I was wondering if there is a way to use the <em>numbafied</em> functions with a <code>pandas</code> <code>rolling</code> object ?</p>