NumPy – Array Manipulation

NumPy - Array Manipulation

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
1Reshape Gives a new shape to an array without changing its data
2Flat A 1-D iterator over the array
3Flatten Returns a copy of the array collapsed into one dimension
4Ravel Returns a contiguous flattened array

Transpose Operations

Sr.No.Operation & Description
1Transpose Permutes the dimensions of an array
2Ndarray.T Same as self.transpose()
3Rollaxis Rolls the specified axis backward
4Swapaxes Interchanges the two axes of an array

Changing Dimensions

Sr.No.Dimension & Description
1Broadcast Produces an object that mimics broadcasting
2Broadcast_to Broadcasts an array to a new shape
3Expand_dims Expands the shape of an array
4Squeeze Removes single-dimensional entries from the shape of an array

Joining Arrays

Sr.No.Array & Description
1Concatenate Joins a sequence of arrays along an existing axis
2Stack Joins a sequence of arrays along a new axis
3Hstack Stacks arrays in sequence horizontally (column-wise)
4Vstack Stacks arrays in sequence vertically (row-wise)

Splitting Arrays

Sr.No.Array & Description
1Split Splits an array into multiple sub-arrays
2Hsplit Splits an array into multiple sub-arrays horizontally (column-wise)
3Vsplit Splits an array into multiple sub-arrays vertically (row-wise)

Adding / Removing Elements

Sr.No.Element & Description
1Resize Returns a new array with the specified shape
2Append Appends the values to the end of an array
3Insert Inserts the values along the given axis before the given indices
4Delete Returns a new array with sub-arrays along an axis deleted
5Unique Finds the unique elements of an array

Next Topic – Click Here

This Post Has 3 Comments

  1. ‏bose qc 25

    Thank you ever so for you article.Really looking forward to read more. Keep writing.

Leave a Reply