Python list indices are 0 based, so len(data)
is not a valid index.
Use
while (i < len(data)):
instead.
However, it looks like you are looping over a Pandas dataframe. You may want to review iterating row by row through a pandas dataframe and What is the most efficient way to loop through dataframes with pandas?