Currently I am working on a python script which extracts measurement data from a text file. I am working with iPython Notebook and Python 2.7
Now I experienced some odd behaviour when working with numpy arrays. I have no explanation for this.
myArray = numpy.zeros((4,3))
myArrayTransposed = myArray.transpose()
for i in range(0,4):
for j in range(0,3):
myArray[i][j] = i+j
print myArray
print myArrayTransposed
leads to:
[[ 0. 1. 2.]
[ 1. 2. 3.]
[ 2. 3. 4.]
[ 3. 4. 5.]]
[[ 0. 1. 2. 3.]
[ 1. 2. 3. 4.]
[ 2. 3. 4. 5.]]
So without working on the transposed array, values are updated in this array.
How is this possible?
myArray.T.copy()if you want a true copy..Tis shorthand for.transpose()