0% found this document useful (0 votes)
3 views4 pages

NumPy

NumPy is an open-source Python library essential for numerical computations, providing support for multi-dimensional arrays and a wide range of mathematical functions. It is widely used in various fields such as data analysis, machine learning, and scientific computing, and integrates well with other libraries like Pandas and SciPy. NumPy's efficient memory usage and performance make it a standard choice for handling large datasets and complex mathematical operations.

Uploaded by

c4379649
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
3 views4 pages

NumPy

NumPy is an open-source Python library essential for numerical computations, providing support for multi-dimensional arrays and a wide range of mathematical functions. It is widely used in various fields such as data analysis, machine learning, and scientific computing, and integrates well with other libraries like Pandas and SciPy. NumPy's efficient memory usage and performance make it a standard choice for handling large datasets and complex mathematical operations.

Uploaded by

c4379649
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 4

NumPy

NumPy, which stands for Numerical Python, is an open-source Python library consisting of
multidimensional and single-dimensional array elements. It's a standard that computes numerical data in
Python. NumPy is most widely used in almost every domain where numerical computation is required,
like science and engineering; hence, the NumPy API functionalities are highly utilized in data science
and scientific Python packages, including Pandas, SciPy, Matplotlib, scikit-learn, scikit-image, and many
more.

Why NumPy - Need of NumPy

• NumPy includes a wide range of mathematical functions for basic arithmetic, linear algebra, Fourier
analysis, and more.
• NumPy performs numerical operations on large datasets efficiently.
• NumPy supports multi-dimensional arrays, allowing for the representation of complex data
structures such as images, sound waves, and tensors in machine learning models.
• It supports the writing of concise and readable code for complex mathematical computations.
• NumPy integrates with other libraries to do scientific computation; these are SciPy (for scientific
computing), Pandas (for data manipulation and analysis), and scikit-learn (for machine learning).
• Many scientific and numerical computing libraries and tools are built on top of NumPy.
• Its widespread adoption and stability make it a standard choice for numerical computing tasks.

NumPy Applications - Uses of NumPy

• Data Analysis
• Machine Learning and Artificial Intelligence
• Scientific Computing
• Array manipulation
• Finance and Economics
• Engineering and Robotics
• Image and Signal Processing
• Data Visualisation

NumPy Datatypes
https://www.javatpoint.com/numpy-datatypes

# Array
1. An array is defined as a collection of items that are stored at contiguous memory location.
2. It is a container which can hold a fixed number of items, and these items should be of the same
type.
3. A combination of arrays saves a lot of time. The array can reduce the overall size of the code.

Advantages of Using Arrays


1. NumPy uses much less memory to store data.
2. NumPy makes it extremely easy to perform mathematical operation on it.
3. Used for the creation of n-dimensional arrays.
4. Finding elements in NumPy array is easy.
Array Creation (Different ways to create array)
https://www.studytonight.com/post/different-ways-of-creating-numpy-arrays
https://www.geeksforgeeks.org/different-ways-to-create-numpy-arrays-in-python/

• Create Array with Random Numbers


o rand(): The function is used to generate a random value between 0 to 1.
EX- var = np.random.rand(4)
print(var)

o randn():The function is used to generate a random value close to zero. This may return positive or
negative numbers as well.
EX- ar_randn = np.random.randn(4,2)
print(ar_randn)

o ranf():The function for doing random sampling in numpy. It returns an array of specified shape and
fills it with random floats in the half-open interval[0.0,1.0).
EX- ar_ranf = np.random.ranf(4)
print(ar_ranf)

o randint():The function is used to generate a random number be in a given range.


EX- ar_randint = np.random.randint(1,1000)
print(ar_randint)

Arrays v/s Lists:


• A List cannot directly handle Mathematical Operation, while Array can.
• An Array consumes less memory than a list.
• Using an Array is faster than List.
• A List can store different datatypes, while you can’t do that in an Array.
• A List is easier to modify since a list store each element individually, it is easier to add and
delete an element than an Array does.
• In Lists one can have nested data with different size, while you cannot do the same in array.

Shape and Reshape function


Reshape - https://www.w3schools.com/python/numpy/numpy_array_reshape.asp
Shape - https://www.geeksforgeeks.org/numpy-array-shape/

Arithmetic Operation on Array


https://www.geeksforgeeks.org/numpy-arithmetic-operations/
Aggregate Functions

Broadcasting
https://numpy.org/doc/stable/user/basics.broadcasting.html
Indexing
https://www.w3schools.com/python/numpy/numpy_array_slicing.asp
Slicing
https://www.geeksforgeeks.org/numpy-slicing-and-indexing/
Iteration in Array
https://www.w3schools.com/python/numpy/numpy_array_iterating.asp
Copy v/s View
https://www.w3schools.com/python/numpy/numpy_copy_vs_view.asp
Joining Array
https://www.w3schools.com/python/numpy/numpy_array_join.asp
Split Array
https://www.w3schools.com/python/numpy/numpy_array_split.asp
Search Array
https://www.w3schools.com/python/numpy/numpy_array_search.asp
Sort Array
https://www.w3schools.com/python/numpy/numpy_array_sort.asp
Filter Array
https://www.w3schools.com/python/numpy/numpy_array_filter.asp
Shuffle
https://www.geeksforgeeks.org/numpy-random-shuffle-in-python/
Unique
https://www.geeksforgeeks.org/python-numpy-np-unique-method/
Resize
https://www.geeksforgeeks.org/python-numpy-numpy-resize/
Flatten
https://www.geeksforgeeks.org/numpy-ndarray-flatten-function-python/
Ravel
https://www.geeksforgeeks.org/numpy-ravel-python/
Insert
https://www.geeksforgeeks.org/numpy-insert-python/
Append
https://www.geeksforgeeks.org/numpy-append-python/
Delete
https://www.geeksforgeeks.org/numpy-delete-python/

Matrix in Array
https://www.geeksforgeeks.org/numpy-matrix-python/
Arithmetic Operation in Matrix
https://www.w3schools.com/python/numpy/numpy_ufunc_simple_arithmetic.asp
Functions
▪ Transpose
https://www.geeksforgeeks.org/python-numpy-matrix-transpose/
▪ Swapaxis
https://www.geeksforgeeks.org/numpy-swapaxes-function-python/
▪ Inverse
https://www.geeksforgeeks.org/how-to-inverse-a-matrix-using-numpy/
▪ Power
https://www.geeksforgeeks.org/raise-a-square-matrix-to-the-power-n-in-linear-algebra-
using-numpy-in-python/
▪ Determinate
https://www.geeksforgeeks.org/how-to-calculate-the-determinant-of-a-matrix-using-numpy/

You might also like