for i in range(122): if i <= 121: for j in range(6): consumption = consumption + df2.loc[df2['Main Load [kWh]']] pos = pos + 1 weekly_consumption=weekly_consumption.append(pos,consumption) consumption = 0 else: for j in range(1): consumption = consumption + df2.loc[df2['Main Load [kWh]']] pos = pos + 1 weekly_consumption=weekly_consumption.append(pos,consumption) consumption = 0
Вы не можете выполнять итерации по числам, но по коллекциям.Вы можете примерить диапазон чисел, например
for i in range(122):
или список, строку и т. Д., Например
for i in '122':