Resolved: Python get datetime intervals of x minutes between two datetime objects

In this post, we will see how to resolve Python get datetime intervals of x minutes between two datetime objects

Question:

How can I get the list of intervals (as 2-tuples) of x minutes between to datetimes? It should be easy but even pandas.date_range() returns exacts intervals, dropping end time. For example:
In:
Expected:

Best Answer:

Here is one way to do it with Pandas to_datetime, DateOffset and dt.ceil:
Then:

If you have better answer, please add a comment about this, thank you!

Source: Stackoverflow.com