I'm trying to create a new column which is division of previous of row. But some of the rows have 0 value. So my conditionl statement is: If the division between 2 rows is infinity or nan, the value in Growth rate column will be 0. Else, it will be division with the previous row.
''' n=len(df) for j in range(0,n-1):
if ((df.iloc[j,4]/df.iloc[j-1,4]) == inf):
df['GrowthRate']=0
else:
df['GrowthRate'] = df.iloc[j,4]/df.iloc[j-1,4]
j=j+1
'''
The output is all my values in the column are inf.