Create a dataset using some loops and three macros

New Altair Community Member
Updated by Jocelyn
I have a dataset which contain a column dates. I have three variables a= 2, b= 3, c=1
for (columnName, columnData) in df['dates'].iteritems():
for k in range(0,b-a+1,c):
date1 = datetime.strptime(columnData,"%Y-%m-%dT%H:%M:%S.000Z") - timedelta(days=k)
date2 = datetime.strptime(columnData,"%Y-%m-%dT%H:%M:%S.000Z") - timedelta(days=k+a)
So if first date is 2019-04-10T18:45:00.000Z, output should be
2019-04-10T18:45:00.000Z
2019-04-10T18:30:00.000Z....................
.
.
2019-04-09T12:30:00.000Z
..............
2019-04-08T18:45:00.000Z-> till first iteration
2019-04-09T18:45:00.000Z
2019-04-09T18:30:00.000Z...........
.
2019-04-08T03:30:00.000Z
.
2019-04-07T18:45:00.000Z-> till second iteration and till final result (there will be only iteration for this case).
Alternate explanation: if date is 2019-04-10T18:45:00.000Z, if b=3 that means start date will be 10 and end date will be 7, for 4 it would be from 10 to 6. But based on the value of 'a' it will get split. So if a=2 then split will (for b=3)
First: 10 to 8
Second: 9 to 7
if a=3 (for b=3), then
First: 10 to 7 (Thats it).
One more part is there (can be ignored for now can see later) mentioned below:
one more factor that is c, which decide the jump of date, so if b=3, a=2, c= 1
First: 10 to 8
Second: 9 to 7. As you can see jump from 10 to 9.
However if b=3, a=2, c= 2
First: 10 to 8. Thats it as based on b=3 it can go from 10 to 7. Based on c=2 ,next jump would be from 8 to 6. However it can't cross 7 so it gave one output.
So if first date is 2019-04-10T18:45:00.000Z, output should be
2019-04-10T18:45:00.000Z
2019-04-10T18:30:00.000Z....................
.
.
2019-04-09T12:30:00.000Z
..............
2019-04-08T18:45:00.000Z-> till first iteration
2019-04-09T18:45:00.000Z
2019-04-09T18:30:00.000Z...........
.
2019-04-08T03:30:00.000Z
.
2019-04-07T18:45:00.000Z-> till second iteration and till final result (there will be only iteration for this case).
Alternate explanation: if date is 2019-04-10T18:45:00.000Z, if b=3 that means start date will be 10 and end date will be 7, for 4 it would be from 10 to 6. But based on the value of 'a' it will get split. So if a=2 then split will (for b=3)
First: 10 to 8
Second: 9 to 7
if a=3 (for b=3), then
First: 10 to 7 (Thats it).
One more part is there (can be ignored for now can see later) mentioned below:
one more factor that is c, which decide the jump of date, so if b=3, a=2, c= 1
First: 10 to 8
Second: 9 to 7. As you can see jump from 10 to 9.
However if b=3, a=2, c= 2
First: 10 to 8. Thats it as based on b=3 it can go from 10 to 7. Based on c=2 ,next jump would be from 8 to 6. However it can't cross 7 so it gave one output.