Technology3 min read

Python_Numpy Introduction

Abhishek Ahlawat

By Abhishek Ahlawat — Recently

Founder of StudyTonight and a MERN fullstack developer. Writes about JavaScript, web development, Linux, and tech.

Summarize this article using AI

NumPy is an extremely popular Python Module. It is a general-purpose array-processing package ehich provides a high-performance multidimensional array object, and tools for working with these arrays.
It is the fundamental package for scientific computing with Python.

For eg : if we work on problem of medical field where we need to improve the patient’s health with minimum costs. Use cases of ML are making near perfect diagnoses, recommend best medicines, predict readmissions and identify high-risk patients. These predictions are based on the dataset of patient records and symptoms exhibited by a patient. Then to handle this extensive data set and finding out the results, we will use NumPy techniques along with other Pyhton libraries like Pandas, Matplotlib.

So, the question arises why it is so popular ??

  • It is widely used in scientific computing, data mining, data analysis, machine learning e.t.c.
  • Provides Sophisticated (broadcasting) functions.
  • It has a powerful command over N-dimensional object.
  • It gifts users, the tools for integrating C/C and Fortan code.
  • It's loaded with Useful random number, linear algebra and Fourier transform capabilities.

How to install it ?

You only need to download an installer, and a wizard will guide you through the installation steps. We will give steps to install NumPy here. The steps to install the other libraries are similar. The actions we will take are as follows:

  1. Download installers for Windows from the SourceForge website (refer to the following table). The latest release versions may change, so just choose the one that fits your setup best.
  2. Choose the appropriate version. For example, we chose numpy-1.8.1-win32-superpack-python2.7.exe.
  3. Open the EXE installer by double-clicking on it.
  4. Now, we can see a description of NumPy and its features. Click on the Next button.

    If you have Python installed, it should automatically be detected. If it is not detected, maybe your path settings are wrong.

  5. Click on the Next button if Python is found; otherwise, click on the Cancel button and install Python (NumPy cannot be installed without Python). Click on the Next button. This is the point of no return. Well, kind of, but it is best to make sure that you are installing to the proper directory and so on and so forth. Now the real installation starts. This may take a while

Or you can use cmd this way :

To install NumPy run:

python setup.py install

To perform an in-place build that can be run from the source folder run:

python setup.py build_ext --inplace

The NumPy build system uses distutils and numpy.distutils. setuptools is only used when building via pip or with pythonsetupegg.py. Using virtualenv should work as expected.

Or the most convenient is to use Anaconda.

To install this package with conda run :

conda install -c anaconda numpy 

Now, open up your Python Shell and let's have a look at NumPy working.
How to use NumPy arrays ?

import numpy as np
ar = np.array([2, 4, 6])
arr

array([2, 4, 6])

# Comment : You can access NumPy array elements using index values just like lists in Python
arr[0]
arr[1]

2

4



Spotted something outdated or wrong?

Liked this? See more StudyTonight posts in Google results.

Add StudyTonight as a preferred source
Next questLIVE OPSStep 2 / 3

Practice real incidents in the browser

System Design Ops — put out fires, ship fixes, and stack XP. Reading done. Time to play.

Play System Design
  • +XP

    Every sim

  • Incidents

    Live ops

  • Ranks

    Climb up

Read next