I'm completely lost why my for loop doesn't append the value from another column.
My dataframe looks like this
and my code is like this
i = -1
open_line = []
for line in df["line 1"]:
idx = i + 1
if (0 < line < 1000 and df.iloc[idx]["line 2"] < 0):
open_line.append(df.iloc[idx]["line 2"])
elif line == 1000 and df.iloc[idx]["line 2"] == 1000:
open_line.append("NAN")
elif line == 1000 and 0 < df.iloc[idx]["line 2"] < 1000:
open_line.append("NAN")
elif line < 0:
open_line.append(line)
When I print open_line I get
['NAN', 'NAN', -1]
The problem is when first if statement is passed at row 3 it doesn't append -9 to my list but it just goes on.
Thanks for the help.
