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...

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...

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...

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...

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...

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....