NumPy (Numerical Python) is a popular open-source Python library used for numerical computing and data analysis.
NumPy is often used in combination with other Python libraries, such as Pandas, Matplotlib, and Scikit-learn, to create a complete data analysis ecosystem in Python.
Some of the key features of NumPy :
Fast vectorized operations: NumPy allows you to perform operations on entire arrays rather than looping through each element, which can be much faster.
Broadcasting: NumPy allows you to perform operations between arrays with different shapes and sizes, which makes it easy to perform operations on data that is not the same shape.
Linear algebra: NumPy provides a suite of functions for performing linear algebra operations such as matrix multiplication, eigenvalues, and eigenvectors.
Random number generation: NumPy includes tools for generating random numbers, which are useful for simulations and statistical analysis.
Numpy is used scientific computing with Python.
We can create powerful multidimensional arrays using Numpy.
Numpy requires all elements are to be of same data type. ( This is the main difference with Pandas which can accommodate different data types. )
Installing Numpy
Use in your command prompt or the environment you are using .
pip install numpy
After installation you can add this line to import Numpy inside Python program.
import numpy as np
Getting the Numpy version installed in your system.
import numpy as np
print("Numpy Version : ",np.__version__)
Creating Numpy Array
import numpy as np
npr=np.array([4,5,9])
print(npr) # [4,5,9]
l1=[3,2,8] # List
npr=np.array(l1) # Using List to create np array
print(npr) # [3,2,8]
t1=(8,12,1) # Tuple
npr=np.array(t1) # from tuple to np array
print(npr) # [ 8 12 1]
Numpy installation and creating array at Colab platform using List Tuple and checking the version