Know Numpy
INTRODUCTION:
stands for Numerical Python and is used for handling large, multi-dimensional arrays and matrices. Unlike Python's built-in lists NumPy arrays provide efficient storage and faster processing for numerical and scientific computations. It offers functions for linear algebra and random number generation making it important for data science and machine learning.
CREATING ARRAYS
The numpy array object in Numpy is called ndarray. We can create an ndarray using this function.
import numpy as np
a = np.array([3,4,5,5])
print(a)
DIMENSIONS
1-D Arrays
arr = np.array([1, 2, 3, 4, 5])
print(arr)
[1 2 3 4 5]
2-D Arrays
arr = np.array([[1, 2, 3], [4, 5, 6]])
print(arr)
[[1,2,,3],
[4,5,6]]
3-D arrays
arr = np.array([[[1, 2, 3], [4, 5, 6]], [[1, 2, 3], [4, 5, 6]]])
print(arr)
[[[1, 2, 3],
[4, 5, 6]],
[[1, 2, 3],
[4, 5, 6]]]
ATTRIBUTES OF ARRAYS
Here’s the text content from the image:
COMPARISON: Array vs List
Array
List