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?

May 7, 2022 in Python 533 views

## How do I obtain the index list in a NumPy Array of all the NaN values present using Python?

Hi, it is pretty simple, to be ...READ MORE

## Python pandas: TypeError: tuple indices must be integers or slices, not str

In fact, I get a perfectly good ...READ MORE

+1 vote

## Can anyone help me with this error: TypeError: list indices must be integers or slices, not str

Hi, @Varshap  It’s a TypeError, which tells us ...READ MORE

## TypeError: only integer scalar arrays can be converted to a scalar index with 1D numpy indices array

I am working on a function that ...READ MORE

+1 vote

## View onto a numpy array?

just index it as you normally would. ...READ MORE

## Dimension in python numpy

Use the .shape to print the dimensions ...READ MORE