I have a numpy array called 'MEL' of shape (94824,).
These values contain arrays of different shapes such as (99,13), (54, 13) (87, 13). I'd like to fill the arrays that are smaller than (99,13) with zeros or even better the mean value of that array.
MEL = numpy.ndarray and
for i in MEL: i = <class 'numpy.ndarray'> (i.shape = 99, 13) except for the ones that need to be filled
for j in i: j = <class 'numpy.ndarray'>
Up till now I have this:
max_len = np.max([len(a) for a in MEL])
for i in MEL:
i = np.asarray([np.pad(a, (0, max_len - len(a)), 'constant', constant_values=0) for a in i])
But the shapes remain the same. any suggestions?
len(a)only returns the length along the first dimension of the array. How do you want to fill the small arrays ?