لَآ إِلَـٰهَ إِلَّا هُوَ
LA ILAHA ILLA HU
Allah, Your Lord There Is No Deity Except Him.

## Python Data Science NumPy Introduction

What is NumPy?

NumPy is a Python library used for working with arrays which also has also has functions for working in domain of linear algebra, fourier transform, and matrices.

Numpy is an open source project so you can use it freely, it was created by Travis Oliphant in 2005.

The full form of NumPy is Numerical Python.

Why Use NumPy?

Python lists which serves the purpose of arrays are slow to process. NumPy aims to provide an array object that is up to 50x faster than traditional Python lists.

The array object in NumPy is called ndarray, it provides a lot of supporting functions that make working with ndarray very easy.

Arrays are very frequently used in data science, where speed and resources are very important.

Why is NumPy Faster Than Lists? Because NumPy arrays are stored at one continuous place in memory unlike lists, so processes can access and manipulate them very efficiently.

In computer science this behavior is called locality of reference .

Besides this the other reason why NumPy is faster than lists is because it is optimized to work with latest CPU architectures.

Which Language is NumPy written in?

NumPy is a Python library and is written partially in Python, but most of the parts that require fast computation are written in C or C++.

Where is the NumPy Codebase? The source code for NumPy is located at this github repository

Installation of NumPy

if you have python installed on your pc you can install numpy as under.

Open Command Prompt from the start menu.

Inside the command prompt, type

pip install numpy

press enter

This command will install numpy on your computer after which you can run on python.

Import NumPy

Once NumPy is installed, import it in your applications by adding the import keyword.

import numpy

Now NumPy is imported and ready to use.

Example

Code

import numpy

arr = numpy.array([1, 2, 3, 4, 5, 6, 7, 8, 9])

print(arr)

the output will be

[1, 2, 3, 4, 5, 6, 7, 8, 9]

Explanation

NumPy as np

NumPy is usually imported under the np alias.

alias: In Python alias are an alternate name for referring to the same thing.

Create an alias with the as keyword while importing

import numpy as np

Now the NumPy package can be referred to as np instead of numpy.

Example

Code

import numpy as np

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

print(arr)

the output will be

import numpy arr = numpy.array([1, 2, 3, 4, 5]) pyscript.write('i2',arr) Checking NumPy Version

The version string is stored under __version__ attribute. Example

Code

import numpy as np

print(np.__version__)

the output will be

import numpy as np pyscript.write('i3',np.__version__)