0
$\begingroup$

When I'm making data transformation pipeline on a dataset I keep getting error as " all the input array dimensions except for concatenation axis must match exactly, but along dimension 0, the array at index 0 has size 1" if someone know what it is, please help, I've tried removing the rows, checked the code but still getting the error

$\endgroup$

1 Answer 1

0
$\begingroup$

When concatenating arrays together, you are effectively "gluing" them onto each other. This only works, if they have the same size along the axis they are concatenated. For example, if your first array is of size 2x5, your second array has to be of size 2x5 as well as all the following arrays. You cannot concatenate a 2x4 array onto the stack of 2x5-sized-arrays.

Your error means that you are concatenating arrays onto each other that are of different shapes. In your specific case as per the error message, the first array is your problem, as its size is different from the others.

To solve this problem, you have to ensure that your arrays along the concatenating axis are all the same shape or size. I cannot tell you exactly how to do that, because I don't know your data or which libraries you are using, but you could do something like this to check the dimensions of the individual arrays:

for array in arrays_along_concat_axis:
    print(array.shape)
$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.