Numpy

https://numpy.org/doc/stable/user/quickstart.html

It is an open-source library that's used in every field of science and engineering. it is used for working with numerical data in python. The NumPy library contains multi-dimensional array and matrix data structure.  It provides ndarray, a homogeneous n-dimensional array object, with methods to efficiently operate on it. NumPy can be used to perform a wide variety of mathematical operations on arrays.

In the Numpy Dimension are called axes

Learning Objectives

After reading, you should be able to:

  • Understand the difference between one-, two- and n-dimensional arrays in NumPy;

  • Understand how to apply some linear algebra operations to n-dimensional arrays without using for-loops;

  • Understand axis and shape properties for n-dimensional arrays.

Numpy array is also called ndarray.

The more important attributes of ndarray objects are:

ndarray.ndim: The number of axes (dimensions) of the array.
ndarray.shape:The dimensions of the array. This is a tuple of integers indicating the size of the array in each dimension.
ndarray.size: The total number of elements of the array. 
ndarray.dtype: An object describing the type of the elements in the array.
ndarray.itemsize: The size in bytes of each element of the array.
ndarray.data: The buffer containing the actual elements of the array.

import numpy as np
a=np.arange(15).reshape(3,5)
print(a.size,a.shape,a.ndim,a.itemsize,a.dtype,type(a),a.data)

Array Creation

a1=np.array([1,2,3,4])

a1=np.array([(1,2,3,4),(4,6,7,9)])
a1

a1=np.array([(1,2,3,4),(4,6,7,9)],dtype=complex)
a1

Numpy offers several function to create an array with initial placeholder content.

Zero function creates an array full of zero, the function one creates an array full of ones and the function 

Empty creates an array whose initial content is random and depends upon the state of memory. 

By default data type of the created array is float64. but it can be specified using keyword dtype.

print(np.ones((3,4),dtype=np.int16))
print(np.zeros((3,5)))
print(np.empty((2,3)))