ValueError: You must specify a freq or x must be a pandas object with a timeseries index
<p>I have obtained time-series data this way:</p>

<pre><code>from pandas.io.data import DataReader
from datetime import datetime
ts_log = DataReader('RUB=X',  'yahoo', datetime(2007,1,1), datetime(2016,8,30))["Adj Close"]
</code></pre>

<p>ts_log looks this way:</p>

<pre><code>Date
2007-01-01    3.269759
2007-01-02    3.269759
2007-01-03    3.270519
  .....        ......
</code></pre>

<p>Then I want to get decomposition by using statsmodels:</p>

<pre><code>from statsmodels.tsa.seasonal import seasonal_decompose
decomposition = seasonal_decompose(ts_log)
</code></pre>

<blockquote>
  <p>ValueError: You must specify a freq or x must be a pandas object with a timeseries index</p>
</blockquote>

<p>To fix this I tried 2 approaches:</p>

<p>1) That won't work, because not every day has a value:</p>

<pre><code>ts_log = pd.DataFrame(data=ts_log.values, index=pd.date_range(start=datetime(2007, 1, 1), 
                                                              end = datetime(2016,8,30), freq='D'), columns=['usd/rub'])
</code></pre>

<p>2) I thought that casting index to datetime should work , but no:</p>

<p><code>ts_log = pd.DataFrame(data=ts_log.values, index=pd.to_datetime(ts_log.index), columns=['usd/rub'])</code></p>

<p>Exactly the same error.</p>

<p>How can I make things to work?</p>

<p>P.S. This code is pretty fine, but I have a bit different data, anyway it should help you catch up the idea:</p>

<pre><code>length = 400
x = np.sin(np.arange(length)) * 10 + np.random.randn(length)
df = pd.DataFrame(data=x, index=pd.date_range(start=datetime(2015, 1, 1), periods=length, freq='w'), columns=['value'])
decomposition = seasonal_decompose(df)
</code></pre>