Check if the dataframe ID or indexing is starting from 0 or 1. Change for loop range value accordingly
# no such element 0 in the dictionary
# Occured when accesing an invalid key usually a dictionary
d={2:3}
print(d[0])
# python keyerror 0 -->because no key 1 present only 2 is there in dictionary
print(d[1])
# python keyerror 1 -->because no key 1 present only 2 is there in dictionary
# Tip use get when accessing unknow dictonary content if we use dict.get(0) we get None as result not an exception