ValueError: setting an array element with a sequence.
- by MedicalMath
This code:
import numpy as p
def firstfunction():
UnFilteredDuringExSummaryOfMeansArray = []
MeanOutputHeader=['TestID','ConditionName','FilterType','RRMean','HRMean','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)
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()
Throws this error message:
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.
However, this code works:
import numpy as p
a=range(24)
b = p.reshape(a,(6,4))
c=p.array(b,dtype=p.float64)[:,2]
I re-arranged the code a bit to put it into a cogent posting, but it should more or less have the same result. Can anyone show me what to do to fix the problem in the broken code above so that it stops throwing an error message?