## NumPy Structured Arrays

Table of Contents Introduction Creating Structured Arrays Compound Data Type Initialization and Printing Indexing and Slicing Filtering with numpy.sort Sorting Introduction This section discusses the use of NumPy structured arrays which provide efficient storage for compound, heterogeneous data. Structured arrays are...

## NumPy Array Search

Table of Contents Introduction The numpy.extract Function The numpy.where Function Returning Indices Returning Modified Array The numpy.insert Function The numpy.searchsorted Function Introduction You can search an array for a certain value and return either the value or the indices corresponding to the value. The...

## NumPy Array Sorting

Table of Contents Introduction The numpy.sort Function Sorting of 1-D arrays Sorting of 2-D arrays The numpy.ndarray.sort Method The numpy.argsort Function. Introduction Sorting an array means rearranging the elements into an ascending or descending ordered sequence. In this article, we will examine the NumPy function...

## NumPy Array Splitting

Table of Contents Introduction The numpy.split Function Splitting of 1-D Arrays Splitting of 2-D Arrays Splitting of 3-D Arrays The numpy.array_split Function The numpy.hsplit Function The numpy.vsplit Function Introduction The opposite of concatenation is splitting, which means breaking up an array into multiple...

## NumPy Array Concatenation

Table of Contents Introduction The numpy.concatenate Function Joining 1-D Arrays Joining 2-D Arrays numpy.vstack: Joining Arrays Vertically numpy.hstack: Joining Arrays Horizontally numpy.stack: Joining Arrays Along a New Axis Introduction Concatenation means joining of two or more arrays into a single array. Several...

## NumPy Array Iteration

Table of Contents Introduction Iterating Over a 1-D Array Iterating Over a 2-D Array Iterating Over a 3-D Array Introduction Iterating over an array means going through the array element by element. We can easily perform this using the Python for loop. However, for large multidimensional arrays, there are certain tools...

## Reshaping NumPy Arrays

Table of Contents Introduction Reshaping an Array The NumPy base Attribute reshape() Method Returns a View The numpy.newaxis Method The Unknown Dimension Flattening an Array Introduction Reshaping an array means changing the shape of an array. To recap, the shape attribute of an ndarray object returns a tuple that...

## NumPy Array Copy vs View

Table of Contents Introduction Python List Slices Return Copies NumPy Array Slices Return Views Creating Copies of NumPy Arrays Introduction NumPy array slices return views rather than copies of the original array. In other words, the copy is a new array whereas the view is just a view of the original array. This is in...

## NumPy Array Slicing

Table of Contents Introduction Slicing of 1-D Arrays Slicing with Positive Indices Slicing with Mixed Indices Slicing of 2-D Arrays. Slicing of 3-D Arrays. Introduction Similar to Python lists, we can can also use access NumPy subarrays with the slice notation with the aid of the colon (:) character. The NumPy slicing...

## NumPy Array Indexing

Table of Contents Introduction The numpy.random.choice() Function Array Indexing for 1-D Arrays Array Indexing for 2-D Arrays Array Indexing for 3-D Arrays Introduction Array indexing is the same as accessing an array element. You can access an array element by referring to its index number, just like a Python list....