I have two for loops that goes through all my dataframe. The goal is to calculate the slope between 2 points on the same line, until the slope reaches 2 or higher. Then it continues on the next row. It goes like this :
step = 0.3
#debut = []
for n in range (ncol-1):
for m in range (nline):
slope = (df.iat[m, (n + 1)] - df.iat[m, n])/step
if slope < 2:
n = n + 1
else:
#tuple(debut)
debut = list(n)
m = m + 1
n = 0
if m > (nline):
break
My dataframe is basic data with an header and a line index.
I want to keep track of the value of 'n', for each row, when it reaches the 2 or higher slope. I tried the debut = list(n)
without success. The list I want would go like this:
1 'column 1 header'
2 'column 2 header'
3 'column 3 header'
...