Skip to content
Advertisement

Creating a series of Quarters

Let say I have a date

import datetime as datetime

mydate = datetime.date(2020, 1, 10)

Now starting from mydate, I want to create an array of 10 quarters e.g. 2020-Q1, 2020-Q2, ... [total 10 values]

Is there any direct way to achieve this?

In R, this is pretty straightforward, as I can use seq() function to generate the same.

Any pointer will be very helpful

Advertisement

Answer

it doesnt give you the exact format … but probably close enough

pandas.date_range("2020-01-01",freq="Q",periods=10).to_period('Q')
User contributions licensed under: CC BY-SA
2 People found this is helpful
Advertisement