Hello.
So I managed to fix it, but I think I had an experience with a bug... It seems that a slice of a numpy array gave me some trouble. Only after redefining the slice as a numpy array would the code run as normal again. In other words:
NOT working:
zk = np.array(list1)
zk2 = zk[a:b]
Working:
zk = np.array(list1)
zk2 = np.array(zk[a:b])
I also checked and it does say that a slice of an array should be an array:
in: zk[a:b]
out: arra(list1[a:b])
The problem was that it would link the two variables zk and zk2 together:
zk = array1
zk2 = array1[a:b]
When i changed zk2[0] to a different value, the corresponding element, zk[a], also changes. So for example:
zk = np.array([1,2,3,4,5])
zk2 = np.array(zk[1:4])
in: print(zk)
print(zk2)
out: array([1,2,3,4,5])
array([2,3,4])
in: zk_2[0] = 0
print(zk)
print(zk2)
out: array([1,0,3,4,5])
array([0,3,4])
Additional information:
- zk is read in from a .csv file using pandas.
- I am using Spyder/Anaconda
-
When i change a value of zk_2 in the command window, zk remains the same
Allright, thought I would let someone know. Let me know if you need additional information.
Kind regards,
Leon