1

I'm trying to pass in df1, df2, df3 & df4 sequentially into the parseTwoPoleBreakers function. However, only df1 is being ran. Is there something wrong with my if elif statements that causing df2, df3 & df4 to not be passed into the parseTwoPoleBreakers function?

i=0
for j in range(0,4):
    if j==0:
        df=df1
    elif j==1:
        df=df2
    elif j==2:
        df=df3
    else:
        df=df4
    #execute this for each dataframe
    while (i<7):
        parseTwoPoleBreakers(7,8,"ab",i,df)
        breakerid+=1
        parseTwoPoleBreakers(9,10,"bc",i,df)
        breakerid+=1
        parseTwoPoleBreakers(11,12,"ca",i,df)
        breakerid+=1
        i+=1
    #j+=1
    print j
1
  • 1
    You could try to print something in your elif statements. What have you done to debug your code? Commented Apr 24, 2016 at 2:13

1 Answer 1

4

I'm trying to pass in df1, df2, df3 & df4 sequentially into the parseTwoPoleBreakers function

Your problem is most likely related to variable scoping inside the if statements or the fact the while i < 7 isn't entered after df1 because i == 7

Use a list instead for the df and did you mean to loop back over the 7 i values?

for df in [df1, df2, df3, df4]:
    #execute this for each dataframe
    for i in range(7):
        parseTwoPoleBreakers(7,8,"ab",i,df)
        breakerid+=1
        parseTwoPoleBreakers(9,10,"bc",i,df)
        breakerid+=1
        parseTwoPoleBreakers(11,12,"ca",i,df)
        breakerid+=1
Sign up to request clarification or add additional context in comments.

1 Comment

Welp, I'll look for someone to insult me for this stupid mistake :P

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.