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>The timestamps in your <code>DatetimeIndex</code> already know that they are describing business month ends, so you can simply add 1:</p>

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

print(repr(dates[-1]))
# =&gt; Timestamp('2016-04-29 00:00:00', offset='BM')

print(repr(dates[-1] + 1))
# =&gt; Timestamp('2016-05-31 00:00:00', offset='BM')
</code></pre>

<p>You can add the latter to your index using <code>.union</code>:</p>

<pre><code>dates = dates.union([dates[-1] + 1])
print(dates)
# =&gt; DatetimeIndex(['2016-01-29', '2016-02-29', '2016-03-31', '2016-04-29',
#                   '2016-05-31'],
#                  dtype='datetime64[ns]', freq='BM')
</code></pre>

<p>Compared to <code>.append</code>, this retains knowledge of the offset.</p>

python pandas datetimeindex