I have an numpy int32 array called a that has shape (4, 8, 3). I want to reshape this array to one that is of size (4, 12, 3). How do I do that?
I have tried using reshape, but reshape requires that the array be the same size.
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
I might be wrong but : a numpy array isn’t supposed to be mutated this way.
When you do a reshape what you’re actually doing is just changing the order/way in which the bytes/elements are read
What you want to do is create a new array that is bigger and contains the data of the previous array plus other stuff. You have to tell Numpy WHERE you want the new stuff and where you want the old stuff.
i.e:
This example adds 4 additionnal “columns” on your array at the end of the second dimension.