In this chapter, we will discuss NumPy – reshape. This function gives a new shape to an array without changing the data. It accepts the following parameters −
numpy.reshape(arr, newshape, order')
Where,
Sr.No. | Parameter & Description |
---|---|
1 | arrArray to be reshaped |
2 | newshapeint or tuple of int. New shape should be compatible to the original shape |
3 | order for C style, ‘F’ for Fortran style, ‘A’ means Fortran like order if an array is stored in Fortran-like contiguous memory, C style otherwise |
Example Of NumPy reshape
import numpy as np a = np.arange(8) print 'The original array:' print a print '\n' b = a.reshape(4,2) print 'The modified array:' print b
Its output would be as follows −
The original array: [0 1 2 3 4 5 6 7] The modified array: [[0 1] [2 3] [4 5] [6 7]]
Next Topic – Click Here
Pingback: NumPy - Array Manipulation - Adglob Infosystem Pvt Ltd
Thanks so much for the article post.Much thanks again.
Pingback: comprar opiniones google
Pingback: molly drug in england,
Pingback: heng99999