Equivalent function of MatLab's "dateshift(...)" in Python?
<p>MatLab can take a date and move it to the end of the month, quarter, etc. using the <code>dateshift(...)</code> <a href="https://www.mathworks.com/help/matlab/ref/dateshift.html" rel="nofollow">function</a>.</p>

<p>Is there an equivalent function in Python?</p>

<p>I'm not sure if it counts as the same, but the <a href="https://docs.python.org/3/library/datetime.html" rel="nofollow"><code>datetime</code></a> module can make times available as a <a href="https://docs.python.org/3/library/datetime.html#datetime.date.timetuple" rel="nofollow"><code>timetuple</code></a>, with separate components for year, month, day etc. This is easy to manipulate directly to advance to the next month, etc.</p>

<p>If you don't mind using an extension, check out <a href="https://dateutil.readthedocs.io/en/stable/" rel="nofollow"><code>dateutil</code></a>. The list of features starts with:</p>

<blockquote>
  <ul>
  <li>Computing of relative deltas (next month, next year, next monday, last week of month, etc); </li>
  </ul>
</blockquote>

<p>The documentation for <a href="https://dateutil.readthedocs.io/en/stable/examples.html#relativedelta-examples" rel="nofollow"><code>dateutil.relativedelta</code></a> shows how to advance to various points.</p>

python matlab date