title: Decompose a time series only in trend and residual with python
body: <p>I want to decompose a time series only in trend and residual (without seasonality). So far, I know I can use statsmodels to decompose a time series, but this includes a seasonality. Is there a way to decompose it without the seasonality?</p>
  
  <p>I have looked at the documentation (<a href="https://www.statsmodels.org/dev/generated/statsmodels.tsa.seasonal.seasonal_decompose.html" rel="nofollow noreferrer">https://www.statsmodels.org/dev/generated/statsmodels.tsa.seasonal.seasonal_decompose.html</a>) seasonal_decompose allows different types of seasonalities ("additive", "multiplicative"}) but I haven't seen a keyword argument that excludes seasonality.</p>
  
  <p>Below a toy model of my problem. A time series with a trend but no seasonality. If we were to remove the seasonal component I think we would get a better fit.<a href="https://i.stack.imgur.com/4EZrC.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/4EZrC.png" alt="Time series decomposition"></a></p>
  
  <pre><code>import numpy as np
  import pandas as pd
  import statsmodels.api as sm
  from statsmodels.tsa.arima_model import ARMA
  from matplotlib import pylab as plt
  
  #defining the trend function
  def trend(t, amp=1):
      return amp*(1 + t)
  
  n_time_steps = 100
  amplitud=1
  #initializing the time series
  time_series = np.zeros(n_time_steps)
  time_series[0] = trend(0, amplitud)
  
  alpha = 0.1
  #making the time series
  for t in range(1,n_time_steps):
      time_series[t] = (1 - alpha)*time_series[t - 1] + alpha*trend(t, amp=amplitud) + alpha*np.random.normal(0,25)
  
  #passing the time series to a pandas format
  dates = sm.tsa.datetools.dates_from_range('2000m1', length=len(time_series))
  time_series_pd= pd.Series(time_series, index=dates)
  #decomposing the time series
  res = sm.tsa.seasonal_decompose(time_series_pd)
  res.plot()
  </code></pre>