<p dir="auto">This is the same issue with <a class="issue-link js-issue-link" data-error-text="Failed to load title" data-id="20347186" data-permission-text="Title is private" data-url="https://github.com/pandas-dev/pandas/issues/5071" data-hovercard-type="issue" data-hovercard-url="/pandas-dev/pandas/issues/5071/hovercard" href="https://github.com/pandas-dev/pandas/issues/5071">#5071</a>, but still not solved. :(</p>
<p dir="auto"><code class="notranslate">func</code> in <code class="notranslate">GroupBy.apply(func, *args, **kwargs)[source]</code> have <code class="notranslate">DataFrame</code>  as an input, while<br>
<code class="notranslate">func</code> in <code class="notranslate">Rolling.apply(func, args=(), kwargs={})</code> have <code class="notranslate">ndarray</code> as an input.</p>
<p dir="auto"><strong>Is this project still actively working to find solution?</strong></p>
<p dir="auto">Also, it would be better if it support parallel processing.</p>
<h2 dir="auto">Code Sample</h2>
<div class="highlight highlight-source-python notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="import pandas as pd

df = pd.DataFrame({'g':[1,1,1,1,2,2,2,3,3,3,3,3],
                   'A':[1,4,2,5,3,5,3,2,1,2,3,6],
                   'B':[1,5,2,3,1,5,7,3,5,2,8,4]})
print(df.groupby('g').apply(lambda x:str(type(x))))
print(df.rolling(3).apply(lambda x:str(type(x))))"><pre class="notranslate"><span class="pl-k">import</span> <span class="pl-s1">pandas</span> <span class="pl-k">as</span> <span class="pl-s1">pd</span>

<span class="pl-s1">df</span> <span class="pl-c1">=</span> <span class="pl-s1">pd</span>.<span class="pl-v">DataFrame</span>({<span class="pl-s">'g'</span>:[<span class="pl-c1">1</span>,<span class="pl-c1">1</span>,<span class="pl-c1">1</span>,<span class="pl-c1">1</span>,<span class="pl-c1">2</span>,<span class="pl-c1">2</span>,<span class="pl-c1">2</span>,<span class="pl-c1">3</span>,<span class="pl-c1">3</span>,<span class="pl-c1">3</span>,<span class="pl-c1">3</span>,<span class="pl-c1">3</span>],
                   <span class="pl-s">'A'</span>:[<span class="pl-c1">1</span>,<span class="pl-c1">4</span>,<span class="pl-c1">2</span>,<span class="pl-c1">5</span>,<span class="pl-c1">3</span>,<span class="pl-c1">5</span>,<span class="pl-c1">3</span>,<span class="pl-c1">2</span>,<span class="pl-c1">1</span>,<span class="pl-c1">2</span>,<span class="pl-c1">3</span>,<span class="pl-c1">6</span>],
                   <span class="pl-s">'B'</span>:[<span class="pl-c1">1</span>,<span class="pl-c1">5</span>,<span class="pl-c1">2</span>,<span class="pl-c1">3</span>,<span class="pl-c1">1</span>,<span class="pl-c1">5</span>,<span class="pl-c1">7</span>,<span class="pl-c1">3</span>,<span class="pl-c1">5</span>,<span class="pl-c1">2</span>,<span class="pl-c1">8</span>,<span class="pl-c1">4</span>]})
<span class="pl-en">print</span>(<span class="pl-s1">df</span>.<span class="pl-en">groupby</span>(<span class="pl-s">'g'</span>).<span class="pl-en">apply</span>(<span class="pl-k">lambda</span> <span class="pl-s1">x</span>:<span class="pl-en">str</span>(<span class="pl-en">type</span>(<span class="pl-s1">x</span>))))
<span class="pl-en">print</span>(<span class="pl-s1">df</span>.<span class="pl-en">rolling</span>(<span class="pl-c1">3</span>).<span class="pl-en">apply</span>(<span class="pl-k">lambda</span> <span class="pl-s1">x</span>:<span class="pl-en">str</span>(<span class="pl-en">type</span>(<span class="pl-s1">x</span>))))</pre></div>
<div class="highlight highlight-text-shell-session notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="g
1    &lt;class 'pandas.core.frame.DataFrame'&gt;
2    &lt;class 'pandas.core.frame.DataFrame'&gt;
3    &lt;class 'pandas.core.frame.DataFrame'&gt;
dtype: object

---------------------------------------------------------------------------
TypeError                                 Traceback (most recent call last)
&lt;ipython-input-497-2f7f95b2a358&gt; in &lt;module&gt;()
----&gt; 1 df.rolling(3).apply(lambda x:str(type(x)))

~/anaconda3/lib/python3.6/site-packages/pandas/core/window.py in apply(self, func, args, kwargs)
   1205     @Appender(_shared_docs['apply'])
   1206     def apply(self, func, args=(), kwargs={}):
-&gt; 1207         return super(Rolling, self).apply(func, args=args, kwargs=kwargs)
   1208 
   1209     @Substitution(name='rolling')

~/anaconda3/lib/python3.6/site-packages/pandas/core/window.py in apply(self, func, args, kwargs)
    854 
    855         return self._apply(f, func, args=args, kwargs=kwargs,
--&gt; 856                            center=False)
    857 
    858     def sum(self, *args, **kwargs):

~/anaconda3/lib/python3.6/site-packages/pandas/core/window.py in _apply(self, func, name, window, center, check_minp, how, **kwargs)
    797             with np.errstate(all='ignore'):
    798                 if values.ndim &gt; 1:
--&gt; 799                     result = np.apply_along_axis(calc, self.axis, values)
    800                 else:
    801                     result = calc(values)

~/anaconda3/lib/python3.6/site-packages/numpy/lib/shape_base.py in apply_along_axis(func1d, axis, arr, *args, **kwargs)
    130     except StopIteration:
    131         raise ValueError('Cannot apply_along_axis when any iteration dimensions are 0')
--&gt; 132     res = asanyarray(func1d(inarr_view[ind0], *args, **kwargs))
    133 
    134     # build a buffer for storing evaluations of func1d.

~/anaconda3/lib/python3.6/site-packages/pandas/core/window.py in calc(x)
    793                 def calc(x):
    794                     return func(x, window, min_periods=self.min_periods,
--&gt; 795                                 closed=self.closed)
    796 
    797             with np.errstate(all='ignore'):

~/anaconda3/lib/python3.6/site-packages/pandas/core/window.py in f(arg, window, min_periods, closed)
    851             minp = _use_window(min_periods, window)
    852             return _window.roll_generic(arg, window, minp, indexi, closed,
--&gt; 853                                         offset, func, args, kwargs)
    854 
    855         return self._apply(f, func, args=args, kwargs=kwargs,

pandas/_libs/window.pyx in pandas._libs.window.roll_generic (pandas/_libs/window.c:36065)()

TypeError: must be real number, not str"><pre class="notranslate"><span class="pl-c1">g</span>
<span class="pl-c1">1    &lt;class 'pandas.core.frame.DataFrame'&gt;</span>
<span class="pl-c1">2    &lt;class 'pandas.core.frame.DataFrame'&gt;</span>
<span class="pl-c1">3    &lt;class 'pandas.core.frame.DataFrame'&gt;</span>
<span class="pl-c1">dtype: object</span>

<span class="pl-c1">---------------------------------------------------------------------------</span>
<span class="pl-c1">TypeError                                 Traceback (most recent call last)</span>
<span class="pl-c1">&lt;ipython-input-497-2f7f95b2a358&gt; in &lt;module&gt;()</span>
<span class="pl-c1">----&gt; 1 df.rolling(3).apply(lambda x:str(type(x)))</span>

<span class="pl-c1">~/anaconda3/lib/python3.6/site-packages/pandas/core/window.py in apply(self, func, args, kwargs)</span>
<span class="pl-c1">   1205     @Appender(_shared_docs['apply'])</span>
<span class="pl-c1">   1206     def apply(self, func, args=(), kwargs={}):</span>
<span class="pl-c1">-&gt; 1207         return super(Rolling, self).apply(func, args=args, kwargs=kwargs)</span>
<span class="pl-c1">   1208 </span>
<span class="pl-c1">   1209     @Substitution(name='rolling')</span>

<span class="pl-c1">~/anaconda3/lib/python3.6/site-packages/pandas/core/window.py in apply(self, func, args, kwargs)</span>
<span class="pl-c1">    854 </span>
<span class="pl-c1">    855         return self._apply(f, func, args=args, kwargs=kwargs,</span>
<span class="pl-c1">--&gt; 856                            center=False)</span>
<span class="pl-c1">    857 </span>
<span class="pl-c1">    858     def sum(self, *args, **kwargs):</span>

<span class="pl-c1">~/anaconda3/lib/python3.6/site-packages/pandas/core/window.py in _apply(self, func, name, window, center, check_minp, how, **kwargs)</span>
<span class="pl-c1">    797             with np.errstate(all='ignore'):</span>
<span class="pl-c1">    798                 if values.ndim &gt; 1:</span>
<span class="pl-c1">--&gt; 799                     result = np.apply_along_axis(calc, self.axis, values)</span>
<span class="pl-c1">    800                 else:</span>
<span class="pl-c1">    801                     result = calc(values)</span>

<span class="pl-c1">~/anaconda3/lib/python3.6/site-packages/numpy/lib/shape_base.py in apply_along_axis(func1d, axis, arr, *args, **kwargs)</span>
<span class="pl-c1">    130     except StopIteration:</span>
<span class="pl-c1">    131         raise ValueError('Cannot apply_along_axis when any iteration dimensions are 0')</span>
<span class="pl-c1">--&gt; 132     res = asanyarray(func1d(inarr_view[ind0], *args, **kwargs))</span>
<span class="pl-c1">    133 </span>
<span class="pl-c1">    134     # build a buffer for storing evaluations of func1d.</span>

<span class="pl-c1">~/anaconda3/lib/python3.6/site-packages/pandas/core/window.py in calc(x)</span>
<span class="pl-c1">    793                 def calc(x):</span>
<span class="pl-c1">    794                     return func(x, window, min_periods=self.min_periods,</span>
<span class="pl-c1">--&gt; 795                                 closed=self.closed)</span>
<span class="pl-c1">    796 </span>
<span class="pl-c1">    797             with np.errstate(all='ignore'):</span>

<span class="pl-c1">~/anaconda3/lib/python3.6/site-packages/pandas/core/window.py in f(arg, window, min_periods, closed)</span>
<span class="pl-c1">    851             minp = _use_window(min_periods, window)</span>
<span class="pl-c1">    852             return _window.roll_generic(arg, window, minp, indexi, closed,</span>
<span class="pl-c1">--&gt; 853                                         offset, func, args, kwargs)</span>
<span class="pl-c1">    854 </span>
<span class="pl-c1">    855         return self._apply(f, func, args=args, kwargs=kwargs,</span>

<span class="pl-c1">pandas/_libs/window.pyx in pandas._libs.window.roll_generic (pandas/_libs/window.c:36065)()</span>

<span class="pl-c1">TypeError: must be real number, not str</span></pre></div>
<p dir="auto">Returning a Series: <a href="http://stackoverflow.com/questions/19121854/using-rolling-apply-on-a-dataframe-object" rel="nofollow">http://stackoverflow.com/questions/19121854/using-rolling-apply-on-a-dataframe-object</a></p>
<p dir="auto">Returning a Scalar: <a href="http://stackoverflow.com/questions/21040766/python-pandas-rolling-apply-two-column-input-into-function/21045831#21045831" rel="nofollow">http://stackoverflow.com/questions/21040766/python-pandas-rolling-apply-two-column-input-into-function/21045831#21045831</a></p>