Array Manipulation

Array Manipulation

Array manipulation has some routines for performing the operations on array-like reshaping, transpose. etc. Let’s discuss some usable and important routines. Let’s start.
1. Changing array shape
A.)Reshape(a, newshape[, order]) -> Gives a new shape to an array without changing its data.
B.)ravel(a[, order]) -> Return a contiguous flattened array.
C.)ndarray.flat -> A 1-D iterator over the array.
D.)ndarray.flatten -> Return a copy of the array collapsed into one dimension.
Changing array shape
2. Transpose Operation
A.) Numpy.moveaxis(a, source, destination ) -> Move axes of an array to new positions. It will be more clear to you through examples only. Just go through comments written with the code which will make easy to understand.
B.) Numpy.transpose(a, axes=None) -> Permute the dimensions of an array.By default, it reverses the dimensions, otherwise, permute the axes according to the values given.
C.) Numpy.ndarray.T -> Same as self.transpose(), except that self is returned if self.ndim
Transpose routine
2. Changing the number of direction
A.) Numpy.atleast_1d -> Convert inputs to arrays with at least one dimension. Scalar inputs are converted to 1-dimensional arrays, whilst higher-dimensional inputs are preserved.
Close Menu