What is meaning of reshape(-1,1)

I know reshape function but i am not able to understand why we are writing (-1,1)

Hello @Deepanshu_garg,

-1 in reshape function is used when you dont know or want to explicitly tell the dimension of that axis. E.g,
If you have an array of shape (2,4) then reshaping it with (-1, 1), then the array will get reshaped in such a way that the resulting array has only 1 column and this is only possible by having 8 rows, hence, (8,1).
Happy Learning :blush:
Thanks

4 Likes