0

I have a dataset from which i need to take the index 0 and 1 then process the output then take the index value 2 and 3 then process the output and so on.

The code which i have tried takes the value of index 0 and 1 then 1 and 2 then 2 and 3 and so on.

for i,r in tqdm(gf.iterrows()):
lp = 0
for v in range(0, 10 + 1):
    lp += r.length_10
    ix.append(i)
    basket.append(r.line.interpolate(lp))

The code must take the index value of o and 1 then 2 and 3 then 4 and 5 and so on....0

2 Answers 2

1
for v in range(0, 10+1,2):
    print(v,v+1)
#prints
#0 1
#2 3
#4 5
#6 7
#8 9
Sign up to request clarification or add additional context in comments.

3 Comments

Why do you need that 10+1? Just do: for value in range(0, 10, 2)
In the question they are using 10+1 or they can use a variable in place of 10
@fiveelements this is done to include the integer 10 as value in range. Basically if you would append v to a list you get values 0,1,2,3,4,5,6,7,8,9,10.
0

Honestly, I couldn't understand very well your code. But, I think that the problem occurs here:

for v in range(0, 10 + 1):

this means that your iterator will go from 0 to 10 one by one, but try to change this line to:

for v in range(0, 10 + 1,2): 

I think this one will do the job

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.