Reputation: 477
I am looping through a range
Loopnumber = []
for i in range(2):
series1 = [10/01/2017, 30,10,2017, 21/11/2017]
loopnumber = ?
Loopnumber.extend(loopnumber)
I wish to create a series of same length as series 1 which a datetime series, and which is of value i and every time the loop runs the values of i are appended to a vector called loopnumber
expected output is
[0, 0, 0, 1, 1, 1, 2, 2, 2]
in this case expected output is
Upvotes: 0
Views: 463
Reputation: 164773
It's not clear why you need this, but you can extend a list within your for
loop. Note also you need range(3)
to iterate 3 times.
loop_list = []
for i in range(3):
series1 = ['10/01/2017', '30,10,2017', '21/11/2017']
loop_list.extend([i]*len(series1))
print(loop_list)
[0, 0, 0, 1, 1, 1, 2, 2, 2]
Upvotes: 1