Please Note array_length should be an integer and not a string:
array_length = len(array_dates)
Also note, your for loop should be constructed using range:
for i in range(array_length): # Use `xrange` for python 2.
Third, i will increment automatically, so delete the bellow line:
i += 1