In this video, we have explained python Numpy that what python Numpy is actually and how we can use it. NumPy is python library which stands for ‘Numerical Python”. It is consist of multidimensional array objects and a collection of functions for processing of array. It is the core library used in scientific computing, with functions present to perform linear algebraic operations and statistical operations. We have explained the key features of Numpy and installation guide for linux. Moreover, we have demonstrated the use of Numpy library with examples.
Commands used in this video for installing Numpy
Installing Numpy by using pip
pip install numpy
Installing Numpy by using conda
conda install -c anaconda numpy
Following is the code that is used in this video for demonstration
simple array
a = np.array([1,2,3])
print(a)
Creating multidimensional array
md_array = np.array([(1, 2, 3), (4, 5, 6)])
print(md_array)
To find the dimension of array
print(md_array.ndim)
To find data type of array’s items
print(md_array.dtype)
Mathematical operations
print(md_array.max())
print(md_array.min())
print(md_array.sum())
print(md_array.mean())
Creating list and converting them to Numpy array
height = [2.1, 2.7, 1.2, 1.5]
weight = [70,60,80,90]
np_height = np.array(height)
np_weight = np.array(weight)
Reshaping the array
original = np.array([('1', 'b', '2', 'b'), ('3', 'r', '4', 'x')])
reshaped = original.reshape(4, 2)
print(original)
print(reshaped)
Linear algebraic functions
matrix = np.array([[1, 2, 3],[4, 5, 6],[7, 8, 9])
print rank of matrix
print(np.linalg.matrix_rank(matrix))
print trace of matrix
print(np.trace(matrix))
print determinant of a matrix
print(np.linalg.det(A))
print inverse of matrix
Print(np.linalg.inv(A))
print transpose of matrix
print(matrix.transpose())
Информация по комментариям в разработке