I have a code where there is a list X
appends multiple lists of different lengths. For instance: the final value of X
after a run can look like this:
X = [[0.6904056370258331, 0.6844439387321473, 0.668782365322113],
[0.7253621816635132, 0.6941058218479157, 0.6929935097694397, 0.6919471859931946, 0.6905447959899902]]
As you can see, X[0]
is of length = 3 while X[1]
is of length = 5. I want to do an element-wise (column-wise) mean of X
to generate a single 1D mean of X
. If I try np.mean(X, axis=0)
it raises error as both X[0]
and X[1]
are of different lengths. Is there a way to achieve what I am looking for, i.e., a single 1D mean of X
?
Thank you,