One of the parts of my script is to determine the area of a graph by the trapezoid approximation. Within the class I created the following function that handles the self.df, which is a DataFrame
def areas(self):
area = 0.
x = list(self.df['wavelenght'])
y = list(self.df['R'])
tamanho = len(self.df)
for i in range(tamanho):
if i == tamanho - 1:
break
x0 = x[i]
y0 = y[i]
x1 = y[i+1]
y1 = y[i+1]
h = x1 - x0
B = y1 + y0
area += (B/2.)*h
print(area)
return area
The line that has print (area) serves to follow the area value in each for loop. In the output text, after several lines with float values comes a time when this occurs
0.514712375
0.517317875
0.51993125
nan
nan
nan
nan
nan
nan
nan
nan
nan
nan
nan
Manually I get the values that these nan should get but I want to manipulate more than 100 DataFrames.
Why are you giving me these exits? What is the best solution?