Alvin Smart Money Management Classification Challenge
Can you classify purchases recorded on Alvin into different categories?
Prize
$3 000 USD
Time
Ended 6 months ago
Participants
220 active · 455 enrolled
Advanced
Classification
Financial Services
how to pad NumPy arrays that don't have the same shape with zeros
Help · 6 Jul 2022, 08:59 · 3

I have a set of NumPy arrays in a list and some of the NumPy arrays don't have the same shape as their other members. I will like to pad them with zeros. Does anyone know how I can achieve this? Thank you

ValueError: could not broadcast input array from the shape (558,10) into shape (558,)

Discussion 3 answers

I suppose you want to fill the 9 next columns of zeros.

X = X.reshape((-1, 1))

padding = np.zeros((558, 9))

X = np.hstack((X, padding))