Convert Pandas tseries object to a DataFrame
<p>I wish to convert the following <code>&lt;'pandas.tseries.resample.DatetimeIndexResampler'&gt;</code> type object into a pandas DataFrame object (<code>&lt;'pandas.core.frame.DataFrame'&gt;</code>). However I cannot find the relevant function in the pandas documentation to allow me to do this. </p>

<p>The data takes the following form:</p>

<pre><code>                  M30
Date                 
2016-02-29  -61.187699
2016-03-31  -60.869565
2016-04-30  -61.717922
2016-05-31  -61.823966
2016-06-30  -62.142100
...
</code></pre>

<p>Can anyone provide an alternative solution?</p>

<p>You need some aggregate function like <code>sum</code> or <code>mean</code>.</p>

<p>Sample with your data:</p>

<pre><code>print (df)
                  M30
Date                 
2016-02-29 -61.187699
2016-03-31 -60.869565
2016-04-30 -61.717922
2016-05-31 -61.823966
2016-06-30 -62.142100

#resample by 2 months
r = df.resample('2M')
print (r)
DatetimeIndexResampler [freq=&lt;2 * MonthEnds&gt;, 
                        axis=0, 
                        closed=right, 
                        label=right, 
                        convention=start, 
                        base=0]
</code></pre>



<pre><code>#aggregate sum
print (r.sum())
                   M30
Date                  
2016-02-29  -61.187699
2016-04-30 -122.587487
2016-06-30 -123.966066

#aggregate mean
print (r.mean())
                  M30
Date                 
2016-02-29 -61.187699
2016-04-30 -61.293743
2016-06-30 -61.983033

#aggregate first
print (r.first())
                  M30
Date                 
2016-02-29 -61.187699
2016-04-30 -60.869565
2016-06-30 -61.823966
</code></pre>

python pandas dataframe time-series resampling