0
One of the parts of my script aims to determine the area of a graph by trapezoid approximation. Within the class I created the following function that manipulates 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 cycle. 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
I can manually get the values 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?
tamanho = len(self.df)
would not betamanho = len(self.df['R'])
?– Isac
Both will give the same value, in this case it is the number of lines that the dataframe has
– Hugo Azevedo