Code Sample,


#series example then old example that threw the future warning commented out
housing_data['ma_apply_example'] = Series.rolling(window=10,center=False).apply(housing_data['M30'], moving_average)
#housing_data['ma_apply_example'] = pd.rolling_apply(housing_data['M30'], 125, moving_average)


error
C:/Users/josheeg/.spyder-py3/pyrollingstatstut15.py:42: FutureWarning: pd.rolling_apply is deprecated for Series and will be removed in a future version, replace with 
        Series.rolling(window=125,center=False).apply(func=<function>,args=<tuple>,kwargs=<dict>)
  housing_data['ma_apply_example'] = pd.rolling_apply(housing_data['M30'], 125, moving_average)

Problem description

[I am running anaconda python 64 bit in windows 10 I am trying pythonprogramming.net tutorial 15 rolling window apply the future warning rolling_apply is being fased out for series.rolling but when I try what it sugjests I get a error. C:/Users/josheeg/.spyder-py3/pyrollingstatstut15.py:42: FutureWarning: pd.rolling_apply is deprecated for Series and will be removed in a future version, replace with Series.rolling(window=125,center=False).apply(func=,args=,kwargs=) housing_data['ma_apply_example'] = pd.rolling_apply(housing_data['M30'], 125, moving_average)]

Error when I try that from my interpritation File "C:/Users/josheeg/.spyder-py3/pyrollingstatstut15.py", line 50, in housing_data['ma_apply_example'] = Series.rolling(window=10,center=False).apply(housing_data['M30'], moving_average)

TypeError: rolling() missing 1 required positional argument: 'self'

I updated all anaconda modules in anaconda navigator

Expected Output

Output of pd.show_versions()

[paste the output of ``pd.show_versions()`` here below this line]

Comment From: TomAugspurger

I think you want housing_data['M30'].rolling(window=10,center=False).apply(125, moving_average)

IOW, use the bound method of a Series instance, not the Series.method.

Hard to say without a copy-pastable example though.

Comment From: josheeg

I still do not understand IOW or how to set that up "bound method of a Series instance. I can try "housing_data['M30'].rolling(window=10,center=False).apply(125, moving_average)"

housing_data['ma_apply_example'] = Series.rolling(housing_data['M30'].rolling(window=10,center=False).apply(125, moving_average))

runfile('C:/Users/josheeg/.spyder-py3/pyrollingstatstut15.py', wdir='C:/Users/josheeg/.spyder-py3') Value US_HPI M30 GDP US_HPI_future label Date
1990-03-31 0.002993 0.004495 0.090909 -0.234375 0.005392 1 1990-04-30 0.003595 0.005392 0.119048 4.265306 0.005285 0 1990-05-31 0.003530 0.005285 0.117021 -1.092539 0.005122 0 1990-06-30 0.003427 0.005122 -0.304762 3.115183 0.003759 0 1990-07-31 0.002519 0.003759 -0.164384 0.441476 0.000566 0 Traceback (most recent call last):

File "", line 1, in runfile('C:/Users/josheeg/.spyder-py3/pyrollingstatstut15.py', wdir='C:/Users/josheeg/.spyder-py3')

File "C:\Users\josheeg\Anaconda3\lib\site-packages\spyder\utils\site\sitecustomize.py", line 705, in runfile execfile(filename, namespace)

File "C:\Users\josheeg\Anaconda3\lib\site-packages\spyder\utils\site\sitecustomize.py", line 102, in execfile exec(compile(f.read(), filename, 'exec'), namespace)

File "C:/Users/josheeg/.spyder-py3/pyrollingstatstut15.py", line 50, in housing_data['ma_apply_example'] = Series.rolling(housing_data['M30'].rolling(window=10,center=False).apply(125, moving_average))

File "C:\Users\josheeg\Anaconda3\lib\site-packages\pandas\core\window.py", line 1224, in apply return super(Rolling, self).apply(func, args=args, kwargs=kwargs)

File "C:\Users\josheeg\Anaconda3\lib\site-packages\pandas\core\window.py", line 862, in apply center=False)

File "C:\Users\josheeg\Anaconda3\lib\site-packages\pandas\core\window.py", line 807, in _apply result = calc(values)

File "C:\Users\josheeg\Anaconda3\lib\site-packages\pandas\core\window.py", line 801, in calc closed=self.closed)

File "C:\Users\josheeg\Anaconda3\lib\site-packages\pandas\core\window.py", line 859, in f offset, func, args, kwargs)

File "pandas/_libs/window.pyx", line 1475, in pandas._libs.window.roll_generic

TypeError: 'function' object is not iterable

runfile('C:/Users/josheeg/.spyder-py3/pyfinancetut1.py', wdir='C:/Users/josheeg/.spyder-py3')

Comment From: TomAugspurger

Do you have a minimal example? http://stackoverflow.com/help/mcve

On Thu, Mar 1, 2018 at 10:33 AM, josheeg notifications@github.com wrote:

I still do not understand IOW or how to set that up "bound method of a Series instance. I can try "housing_data['M30'].rolling(window=10,center=False).apply(125, moving_average)"

housing_data['ma_apply_example'] = Series.rolling(housing_data[' M30'].rolling(window=10,center=False).apply(125, moving_average))

runfile('C:/Users/josheeg/.spyder-py3/pyrollingstatstut15.py', wdir='C:/Users/josheeg/.spyder-py3') Value US_HPI M30 GDP US_HPI_future label Date 1990-03-31 0.002993 0.004495 0.090909 -0.234375 0.005392 1 1990-04-30 0.003595 0.005392 0.119048 4.265306 0.005285 0 1990-05-31 0.003530 0.005285 0.117021 -1.092539 0.005122 0 1990-06-30 0.003427 0.005122 -0.304762 3.115183 0.003759 0 1990-07-31 0.002519 0.003759 -0.164384 0.441476 0.000566 0 Traceback (most recent call last):

File "", line 1, in runfile('C:/Users/josheeg/.spyder-py3/pyrollingstatstut15.py', wdir='C:/Users/josheeg/.spyder-py3')

File "C:\Users\josheeg\Anaconda3\lib\site-packages\spyder\utils\site\sitecustomize.py", line 705, in runfile execfile(filename, namespace)

File "C:\Users\josheeg\Anaconda3\lib\site-packages\spyder\utils\site\sitecustomize.py", line 102, in execfile exec(compile(f.read(), filename, 'exec'), namespace)

File "C:/Users/josheeg/.spyder-py3/pyrollingstatstut15.py", line 50, in housing_data['ma_apply_example'] = Series.rolling(housing_data[' M30'].rolling(window=10,center=False).apply(125, moving_average))

File "C:\Users\josheeg\Anaconda3\lib\site-packages\pandas\core\window.py", line 1224, in apply return super(Rolling, self).apply(func, args=args, kwargs=kwargs)

File "C:\Users\josheeg\Anaconda3\lib\site-packages\pandas\core\window.py", line 862, in apply center=False)

File "C:\Users\josheeg\Anaconda3\lib\site-packages\pandas\core\window.py", line 807, in _apply result = calc(values)

File "C:\Users\josheeg\Anaconda3\lib\site-packages\pandas\core\window.py", line 801, in calc closed=self.closed)

File "C:\Users\josheeg\Anaconda3\lib\site-packages\pandas\core\window.py", line 859, in f offset, func, args, kwargs)

File "pandas/libs/window.pyx", line 1475, in pandas._libs.window.roll generic

TypeError: 'function' object is not iterable

runfile('C:/Users/josheeg/.spyder-py3/pyfinancetut1.py', wdir='C:/Users/josheeg/.spyder-py3')

— You are receiving this because you modified the open/close state. Reply to this email directly, view it on GitHub https://github.com/pandas-dev/pandas/issues/19953#issuecomment-369649907, or mute the thread https://github.com/notifications/unsubscribe-auth/ABQHImJyCkPE3NA30vrQgR6XSQq4i4tiks5taCLggaJpZM4SYe7l .