Still no answer? Here is something that is not pretty but does the job to cut the time range into chunks with a rest IF the start date is provided (as indicated) for the first of the month:
import pandas as pd
def get_installs_time(client, appId, startDate, endDate, blockLength):
s = pd.date_range(start=startDate, end=endDate, freq=str(blockLength)+"MS", closed="left")
e = (s[1:]-pd.to_timedelta(1, unit='D'))
return list(zip(s.strftime('%Y-%m-%d').tolist(), e.strftime('%Y-%m-%d').tolist() + [endDate]))
print(get_installs_time("X", "Y", '2020-03-01', '2021-01-01', 3))
Sample output:
[('2020-03-01', '2020-05-31'), ('2020-06-01', '2020-08-31'), ('2020-09-01', '2020-11-30'), ('2020-12-01', '2021-01-01')]
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…