Numpyinpython1713425437 (1)
Numpyinpython1713425437 (1)
• 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
INSTALLATION OF NUMPY
• import numpy
NUMPY AS NP
0-D Arrays
• 0-D arrays, or Scalars, are the elements in an array. Each value in an
array is a 0-D array.
DIMENSIONS IN ARRAYS
1-D Arrays
• An array that has 0-D arrays as its elements is called uni-dimensional
or 1-D array.
• These are the most common and basic arrays.
DIMENSIONS IN ARRAYS
2-D Arrays
• An array that has 1-D arrays as its elements is called a 2-D array.
• These are often used to represent matrix or 2nd order tensors.
NUMBER OF DIMENSIONS
• NumPy Arrays provides the ndim attribute that returns an integer that tells us
how many dimensions the array have.
METHODS FOR CREATING NUMPY ARRAY
The result includes the start index, but excludes the end index.
NUMPY ARRAY SLICING