I want to create 3 numpy arrays/lists using data from another array called mean_data as follows:
-- 39 R = np.array(mean_data[:,0])
40 P = np.array(mean_data[:,1])
41 Z = np.array(mean_data[:,2])
I get this error when I run this code:
TypeError: list indices must be integers, not tuple
I have tried creating mean_data as an np.array and using np.append to add values to it but that doesn't solve the problem either.
Here's the traceback:
Traceback (most recent call last):
File "polarplot.py", line 36, in <module>
R = np.array(mean_data[:,0])
TypeError: list indices must be integers, not tuple
This is how I tried creating an array:
mean_data = np.array([])
for ur, ua in it.product(uradius, uangle):
samepoints = (data[:,0]==ur) & (data[:,1]==ua)
if samepoints.sum() > 1: # check if there is more than one match
np.append(mean_data[ur, ua, np.mean(data[samepoints,-1])])
elif samepoints.sum() == 1:
np.append(mean_data, [ur, ua, data[samepoints,-1]])
This is the the traceback on that :
IndexError Traceback (most recent call last)
<ipython-input-3-5268bc25e75e> in <module>()
31 samepoints = (data[:,0]==ur) & (data[:,1]==ua)
32 if samepoints.sum() > 1: # check if there is more than one match
---> 33 np.append(mean_data[ur, ua, np.mean(data[samepoints,-1])])
34 elif samepoints.sum() == 1:
35 np.append(mean_data, [ur, ua, data[samepoints,-1]])
IndexError: invalid index
Can someone guide me in solving this?