



























































Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
Prepare for your exams
Study with the several resources on Docsity
Earn points to download
Earn points by helping other students or get them with a premium plan
Community
Ask the community for help and clear up your study doubts
Discover the best universities in your country according to Docsity users
Free resources
Download our free guides on studying techniques, anxiety management strategies, and thesis advice from Docsity tutors
A comprehensive guide to numpy, a fundamental library for numerical computing in python. It covers key concepts such as array creation, data types, indexing, slicing, array operations, and mathematical functions. The document also includes practical examples and explanations to help users understand and apply numpy effectively.
Typology: Study notes
1 / 67
This page cannot be seen from the preview
Don't miss anything!
Manpreet Kaur(Python and Data Science
Manpreet Kaur(Python and Data Science
Manpreet Kaur(Python and Data Science
Manpreet Kaur(Python and Data Science
(numpy)
Manpreet Kaur(Python and Data Science
How to install Numpy
Import NumPy
Manpreet Kaur(Python and Data Science
Data Types in NumPy
Manpreet Kaur(Python and Data Science
Checking the Data Type of an Array
Manpreet Kaur(Python and Data Science
array() Function
Manpreet Kaur(Python and Data Science
Creating 1D Arrya using array() Function
Manpreet Kaur(Python and Data Science
index
Manpreet Kaur(Python and Data Science
Create a NumPy ndarray Object
Manpreet Kaur(Python and Data Science
Check Number of Dimensions?
NumPy Arrays provides the ndim attribute that returns an integer that tells us how many dimensions the array have.
import numpy as np
a = np.array(42) b = np.array([1, 2, 3, 4, 5]) c = np.array([[1, 2, 3], [4, 5, 6]]) d = np.array([[[1, 2, 3], [4, 5, 6]], [[1, 2, 3], [4, 5, 6]]])
print(a.ndim) print(b.ndim) print(c.ndim) print(d.ndim)
Manpreet Kaur(Python and Data Science
Higher Dimensional Arrays
An array can have any number of dimensions.
When the array is created, you can define the number of dimensions by using the ndmin argument.
Example :
import numpy as np
arr = np.array([1, 2, 3, 4], ndmin=5)
print(arr) print('number of dimensions :', arr.ndim)
Manpreet Kaur(Python and Data Science