Docsity
Docsity

Prepare for your exams
Prepare for your exams

Study with the several resources on Docsity


Earn points to download
Earn points to download

Earn points by helping other students or get them with a premium plan


Guidelines and tips
Guidelines and tips

NumPy: The Python Library for Faster Array Processing, Cheat Sheet of Mathematics

Numpy is a powerful python library designed for handling arrays and matrices, providing significant performance gains compared to python lists. With numpy, users can create, manipulate, and process multi-dimensional arrays, called ndarrays, which are stored in contiguous memory for optimal efficiency. This library also offers a range of supporting functions to simplify array operations.

Typology: Cheat Sheet

2022/2023

Uploaded on 12/22/2022

Sahil1239
Sahil1239 🇮🇳

4 documents

1 / 2

Toggle sidebar

This page cannot be seen from the preview

Don't miss anything!

bg1
NumPy
NumPy is a Python library used for working with arrays.
NumPy stands for Numerical Python. In Python we have lists that serve the purpose of arrays, but they 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.
NumPy Faster Than Lists
NumPy arrays are stored at one continuous place in memory unlike lists, so processes can access
and manipulate them very efficiently.
This behavior is called locality of reference in computer science.
This is the main reason why NumPy is faster than lists. Also it is optimized to work with latest
CPU architectures.
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
import numpy
arr = numpy.array([1, 2, 3, 4, 5])
print(arr)
import numpy as np
Now the NumPy package can be referred to as np instead of numpy.
Example
import numpy as np
arr = np.array([1, 2, 3, 4, 5])
print(arr)
pf2

Partial preview of the text

Download NumPy: The Python Library for Faster Array Processing and more Cheat Sheet Mathematics in PDF only on Docsity!

NumPy

NumPy is a Python library used for working with arrays. NumPy stands for Numerical Python. In Python we have lists that serve the purpose of arrays, but they 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.

NumPy Faster Than Lists

NumPy arrays are stored at one continuous place in memory unlike lists, so processes can access

and manipulate them very efficiently.

This behavior is called locality of reference in computer science.

This is the main reason why NumPy is faster than lists. Also it is optimized to work with latest

CPU architectures.

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 import numpy arr = numpy.array([ 1 , 2 , 3 , 4 , 5 ]) print(arr) import numpy as np

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

Example import numpy as np arr = np.array([ 1 , 2 , 3 , 4 , 5 ]) print(arr)