extend a pandas datetimeindex by 1 period
<p>consider the <code>DateTimeIndex</code> <code>dates</code></p>

<pre><code>dates = pd.date_range('2016-01-29', periods=4, freq='BM')
dates

DatetimeIndex(['2016-01-29', '2016-02-29', '2016-03-31', '2016-04-29'],
              dtype='datetime64[ns]', freq='BM')
</code></pre>

<p>I want to extend the index by one period at the frequency attached to the object.</p>

<hr>

<p>I expect</p>

<pre><code>pd.date_range('2016-01-29', periods=5, freq='BM')

DatetimeIndex(['2016-01-29', '2016-02-29', '2016-03-31', '2016-04-29',
               '2016-05-31'],
              dtype='datetime64[ns]', freq='BM')
</code></pre>

<hr>

<p>I've tried</p>

<pre><code>dates.append(dates[[-1]] + pd.offsets.BusinessMonthEnd())
</code></pre>

<p>However</p>

<ul>
<li>Not generalized to use frequency of <code>dates</code></li>
<li>I get a performance warning

<blockquote>
  <p>PerformanceWarning: Non-vectorized DateOffset being applied to Series or DatetimeIndex</p>
</blockquote></li>
</ul>

<p>try this:</p>

<pre><code>In [207]: dates = dates.append(pd.DatetimeIndex(pd.Series(dates[-1] + pd.offsets.BusinessMonthEnd())))

In [208]: dates
Out[208]: DatetimeIndex(['2016-01-29', '2016-02-29', '2016-03-31', '2016-04-29', '2016-05-31'], dtype='datetime64[ns]', freq=None)
</code></pre>

<p>or using <code>list</code> (<code>[...]</code>) instead of <code>pd.Series()</code>:</p>

<pre><code>In [211]: dates.append(pd.DatetimeIndex([dates[-1] + pd.offsets.BusinessMonthEnd()]))
Out[211]: DatetimeIndex(['2016-01-29', '2016-02-29', '2016-03-31', '2016-04-29', '2016-05-31'], dtype='datetime64[ns]', freq=None)
</code></pre>

python pandas datetimeindex