In this chapter, we will discuss about NumPy Array Manipulation. Several routines are available in the NumPy package for manipulation of elements in ndarray object. And they can be classified −
Types NumPy Array Manipulation
Changing Shape
Sr.No. Shape & Description 1 Reshape Gives a new shape to an array without changing its data2 Flat A 1-D iterator over the array3 Flatten Returns a copy of the array collapsed into one dimension4 Ravel Returns a contiguous flattened array
Transpose Operations
Sr.No. Operation & Description 1 T ranspose Permutes the dimensions of an array2 Ndarray.T Same as self.transpose()3 Rollaxis Rolls the specified axis backward4 Swapaxes Interchanges the two axes of an array
Changing Dimensions
Sr.No. Dimension & Description 1 Broadcast Produces an object that mimics broadcasting2 Broadcast_to Broadcasts an array to a new shape3 Expand_dims Expands the shape of an array4 Squeeze Removes single-dimensional entries from the shape of an array
Joining Arrays
Sr.No. Array & Description 1 Concatenate Joins a sequence of arrays along an existing axis2 Stack Joins a sequence of arrays along a new axis3 Hstack Stacks arrays in sequence horizontally (column-wise)4 Vstack Stacks arrays in sequence vertically (row-wise)
Splitting Arrays
Sr.No. Array & Description 1 Split Splits an array into multiple sub-arrays2 Hsplit Splits an array into multiple sub-arrays horizontally (column-wise)3 Vsplit Splits an array into multiple sub-arrays vertically (row-wise)
Adding / Removing Elements
Sr.No. Element & Description 1 Resize Returns a new array with the specified shape2 Append Appends the values to the end of an array3 Insert Inserts the values along the given axis before the given indices4 Delete Returns a new array with sub-arrays along an axis deleted5 Unique Finds the unique elements of an array
Next Topic – Click Here
Pingback: NumPy - Iterating Over Array - Adglob Infosystem Pvt Ltd
Enjoyed every bit of your article.Much thanks again. Fantastic.
Thank you ever so for you article.Really looking forward to read more. Keep writing.