What is NumPy?

NumPy is an open-source Python library that is used in scientific computing. It was created by Travis Oliphant.

NumPy supports large n-dimensional arrays (also known as ndarrays) and matrices. It comes preloaded with numerous handy mathematical functions for these n-dimensional arrays.

Where do we use NumPy?

NumPy is capable of driving all machine learning and deep learning models. The simplest units of these models are stored as NumPy arrays.

Other prominent uses of NumPy include:

1. Pandas DataFrames are converted internally into NumPy arrays for a wide variety of tasks.
2. Graphing libraries such as Matplotlib also implicitly or explicitly take NumPy ndarrays to create visualizations.

NumPy offers faster operations in comparison with Python lists. Many NumPy operations are internally implemented in C, thereby reducing the time spent on factors like Python loops.

How can you get started with NumPy?

Installing NumPy

1. If you use pip, then type the following command to install NumPy as part of your Python environment:

``python -m pip install numpy``

2. If you use Anaconda, then you don’t have to install anything since it comes pre-installed with the latest version of NumPy.

3. Once installed, import NumPy in your Python shell with the following command:

``import numpy as np``

4. After the import, you can start doing operations.

Creating NumPy arrays

Run the following command to create two NumPy arrays:

``````arr_1 = np.array([1,2,3])
arr_2 = np.array([2,2,2,])``````

Mathematical functions in NumPy

To take the dot product of two NumPy arrays, use NumPy’s built-in dot function.

``np.dot(arr_1, arr_2)``

``np.add(arr_1, arr_2)``