I am getting this error:

```File "mypath\mypythonscript.py", line 3484, in secondfunction
RRDuringArray = p.array(UnFilteredDuringExSummaryOfMeansArray,dtype=p.float64)[1:,3]
ValueError: setting an array element with a sequence.```

When I run this python code:

```import numpy as p

def firstfunction():
UnFilteredDuringExSummaryOfMeansArray = []
'dZdtMaxVoltageMean','BZMean','ZXMean','LVETMean','Z0Mean',
'StrokeVolumeMean','CardiacOutputMean','VelocityIndexMean']
dataMatrix = BeatByBeatMatrixOfMatrices[column]
roughTrimmedMatrix = p.array(dataMatrix[1:,1:17])

trimmedMatrix = p.array(roughTrimmedMatrix,dtype=p.float64)  #ERROR THROWN HERE

myMeans = p.mean(trimmedMatrix,axis=0,dtype=p.float64)
conditionMeansArray = [TestID,testCondition,'UnfilteredBefore',myMeans[3], myMeans[4],
myMeans[6], myMeans[9], myMeans[10], myMeans[11], myMeans[12],
myMeans[13], myMeans[14], myMeans[15]]
UnFilteredDuringExSummaryOfMeansArray.append(conditionMeansArray)
secondfunction(UnFilteredDuringExSummaryOfMeansArray)
return

def secondfunction(UnFilteredDuringExSummaryOfMeansArray):
RRDuringArray = p.array(UnFilteredDuringExSummaryOfMeansArray,dtype=p.float64)[1:,3]
return

firstfunction()```

Can someone explain to me how to fix this problem?

Apr 30, 2022 in Python 2,180 views

## 1 answer to this question.

The problem is the shape of the input list isn't a (generalized) "box" that can be turned into a multidimensional array. This error can also happen when you are trying to use a string as an element in an array of type float:

`numpy.array([1.2, "abc"], dtype=float)   # wrong!`

To solve this,  you could use the dtype object, which enables the array to hold arbitrary Python objects:

`numpy.array([1.2, "abc"], dtype=object)`

I hope this helps you.

• 63,720 points

## ValueError: The truth value of an array with more than one element is ambiguous. Use a.any() or a.all()

Hello @kartik, Since different users might have different ...READ MORE

## Reconstruct an array by replacing every element with a[[i-1]%K] - Python

Hey varsha, Have a look at this ...READ MORE

## The truth value of an array with more than one element is ambiguous. Use a.any() or a.all()

I couldn't figure out the problem. here my ...READ MORE

## how do I check the length of an array in a python program?

lets say we have a list mylist = ...READ MORE

## Python Pandas: selecting element in array column

pa.loc[row] selects the row with label row. pa.loc[row, ...READ MORE

## NumPy Array Indexing

If you want to create a subarray ...READ MORE

## Python numpy array of numpy arrays

I have a requirement. I need to ...READ MORE