I am trying to traverse a 2d array with a nested for loop, and it has different values when I graph it, but when I try to access the data, it the elements are all the same. I have tried different styles of for loops but get the same errors. This is more of an error that I don't understand coming from Java.
predicted_values = 2*[2*[0]] # number of lines *[ number of data points *[0]]
for row in predicted_values:
#last given price
row[0] = adj_close[len(adj_close)-1]
for index in xrange(1,len(row)):
random_float_0_1 = random.random()
drift = meanPDR -variance/2
random_offset = standard_deviation*norm.ppf(random_float_0_1)
t = drift + random_offset
predicted_stock_price = row[index-1]*math.exp(t)
row[index] = predicted_stock_price
print predicted_values
plt.plot(range(0,len(row)),row)
This outputs
[[152.186905, 149.88609120889242], [152.186905, 149.88609120889242]]
[[152.186905, 151.0754945683822], [152.186905, 151.0754945683822]]
when I want it to output
[[152.186905, 149.88609120889242], [152.186905, 0]]
[[152.186905, 149.88609120889242], [152.186905, 151.0754945683822]]
What happened to overwrite the previous data that it shouldn't have access to.