In Python, Numpy is a general purpose package for the processing of arrays. It will provide high-performance multi-dimensional array objects and also tools for working with these arrays. In Python, it is a fundamental package for scientific computation in Data Science.
Apart from the scientific uses, Numpy is there as an efficient multi-dimensional container of the generic data.
Arrays in Numpy:
In numpy arrays are table of elements (generally numbers), all of the same type that are index by a tuple of positive integers. Number of dimensions of array is rank of the array in Numpy. Tuple of integers which gives the size of the array along each dimension is known as shape of the array. In Numpy an array class is known as ndarray. We use square brackets for accessing elements and can it can be initialize using nested Python lists.
Creation of Numpy Array:
In Numpy arrays can be there by using multiple ways with various number of ranks, which define the size of the array. For creation of arrays we can also use various data types like lists, tuples, etc. The type of element in the sequence will help us for deducing the type of resultant array.
Note: While creation of arrays, we can explicitly define the type of array.
Accessing the array index:
In case of numpy arrays, indexing or accessing the array index is done in multiple ways. For printing range of an array, slicing needs to be done. Slicing means defining a new array for printing a range of elements from original array. As slice array holds range of elements of original array, modifying the content of the slice array will also modify the original array.
Basic Array Operations:
In numpy, arrays provide a wide range of operations that can be perform on a particular array or combination of arrays. The operations include basic mathematical operations as well as unary and binary operations.
Data Types in Numpy:
All ndarray has an associate data type (dtype) object. The data type object (dtype) will provide information about layout of the array. The values of ndarray are store in buffer, which can be thought of as contiguous block of memory bytes that can be interpret by dtype object. In numpy there are many large sets of numeric datatypes which is there for constructing arrays. When array is create, Numpy tries to guess a datatype, but the functions which construct arrays will also include an optional argument to explicitly specify the datatype.
Construction of a Datatype Object:
In numpy we don’t need to define datatypes of arrays unless a specific datatype is require. When datatype of arrays are not predefine in constructor function, Numpy tries to guess datatype for arrays.
Math Operations on DataType array:
In arrays in Numpy, basic mathematical operations are performe element-wise on array. These operations are applcable both as operator overloads and as functions. There are many useful functions provide in Numpy for performing computation on arrays such as, sum for addition of elements of array, T for transpose of the elements of array, etc.
Methods in Numpy: