title: TypeError: 'Series' object is not callable - Rolling window - Python
body: <p>I have an Hodrick-Prescott (HP) function defined in Python as follows:</p>
  
  <pre><code>import statsmodels.api as sm
  
  def func_HP(close, params):
      cycle,trend = sm.tsa.filters.hpfilter(close,params)
      return trend
  </code></pre>
  
  <p>If i apply that function to a column present in a datafrate like this:</p>
  
  <pre><code>df['Trend'] = func_HP(df['Close'],18000)
  </code></pre>
  
  <p>it works fine and I get the Trend value for the whole "static" column.</p>
  
  <p>I want to apply the HP function to a rolling window of the column df['Close']. The window length is 240. As such, the HP filter will be applied to the rolling 240 records. 
  I have used this code:</p>
  
  <pre><code>x = df.rolling(window=240, min_periods=240, on='Close').apply(func_HP(df['Close'],18000))
  </code></pre>
  
  <p>but I get the error:</p>
  
  <blockquote>
    <p>TypeError: 'Series' object is not callable</p>
  </blockquote>
  
  <p>I guess that is because once you apply the rolling window the column <code>df['Close']</code> becomes an array: is that right?</p>
  
  <p>And what can I do to "convert" the outcome of the rolling selection to a column?</p>