Problems resampling pandas time series with time gap between indices
<p>I want to resample the pandas series </p>

<pre><code>import pandas as pd
index_1 = pd.date_range('1/1/2000', periods=4, freq='T')
index_2 = pd.date_range('1/2/2000', periods=3, freq='T')
series = pd.Series(range(4), index=index_1)
series=series.append(pd.Series(range(3), index=index_2))
print series
&gt;&gt;&gt;2000-01-01 00:00:00    0
   2000-01-01 00:01:00    1
   2000-01-01 00:02:00    2
   2000-01-01 00:03:00    3
   2000-01-02 00:00:00    0
   2000-01-02 00:01:00    1
   2000-01-02 00:02:00    2
</code></pre>

<p>such that the resulting DataSeries only contains every second entry, i.e </p>

<pre><code>  &gt;&gt;&gt;2000-01-01 00:00:00    0
     2000-01-01 00:02:00    2
     2000-01-02 00:00:00    0
     2000-01-02 00:02:00    2
</code></pre>

<p>using the (poorly documented) resample method of pandas in the following way:</p>

<pre><code>resampled_series = series.resample('2T', closed='right')
print resampled_series
</code></pre>

<p>I get </p>

<pre><code>&gt;&gt;&gt;1999-12-31 23:58:00    0.0
   2000-01-01 00:00:00    1.5
   2000-01-01 00:02:00    3.0
   2000-01-01 00:04:00    NaN
   2000-01-01 00:56:00    NaN
                  ...
   2000-01-01 23:54:00    NaN
   2000-01-01 23:56:00    NaN
   2000-01-01 23:58:00    0.0
   2000-01-02 00:00:00    1.5
   2000-01-02 00:02:00    3.0
</code></pre>

<p>Why does it start 2 minutes earlier than the original series? why does it contain all the time steps inbetween, which are not contained in the original series? How can I get my desired result?</p>

<p><code>resample()</code> is not the right function for your purpose.</p>

<p>try this:</p>

<pre><code>series[series.index.minute % 2 == 0]
</code></pre>

python pandas