Updated On : Jul-18,2020 Tags numpy, basics
Learning Numpy - Simple Tutorial For Beginners - NumPy - Array Manipulation Part 12

Learning Numpy - Simple Tutorial For Beginners - NumPy - Array Manipulation Part 12

Several routines are available in NumPy package for manipulation of elements in ndarray object. They can be classified into the following types −

Changing Shape

Parameter Description
reshape Gives a new shape to an array without changing its data
flat A 1-D iterator over the array
flatten Returns a copy of the array collapsed into one dimension
ravel Returns a contiguous flattened array

Transpose Operations

Parameter Description
transpose Permutes the dimensions of an array
ndarray.T Same as self.transpose()
rollaxis Rolls the specified axis backwards
swapaxes Interchanges the two axes of an array

Changing Dimensions

Parameter Description
broadcast Produces an object that mimics broadcasting
broadcast_to Broadcasts an array to a new shape
expand_dims Expands the shape of an array
squeeze Removes single-dimensional entries from the shape of an array

Joining Arrays

Parameter Description
concatenate Joins a sequence of arrays along an existing axis
stack Joins a sequence of arrays along a new axis
hstack Stacks arrays in sequence horizontally (column wise)
vstack Stacks arrays in sequence vertically (row wise)

Splitting Arrays

Parameter Description
concatenate Joins a sequence of arrays along an existing axis
stack Joins a sequence of arrays along a new axis
hstack Stacks arrays in sequence horizontally (column wise)
vstack Stacks arrays in sequence vertically (row wise)

Adding / Removing Elements

Parameter Description
resize Returns a new array with the specified shape
append Appends the values to the end of an array
insert Inserts the values along the given axis before the given indices
delete Returns a new array with sub-arrays along an axis deleted
unique Finds the unique elements of an array
Dolly Solanki  Dolly Solanki

  Support Us

Thank You for visiting our website. If you like our work, please support us so that we can keep on creating new tutorials/blogs on interesting topics (like AI, ML, Data Science, Python, Digital Marketing, SEO, etc.) that can help people learn new things faster. You can support us by clicking on the Coffee button at the bottom right corner. We would appreciate even if you can give a thumbs-up to our article in the comments section below.

 Want to Share Your Views? Have Any Suggestions?

If you want to

  • provide some suggestions on topic
  • share your views
  • include some details in tutorial
  • suggest some new topics on which we should create tutorials/blogs
Please feel free to let us know in the comments section below (Guest Comments are allowed). We appreciate and value your feedbacks.