NumPy (Numerical Python) is a Python library that comprises of multidimensional arrays and numerous functions to perform various mathematical and logical operations on them. NumPy also consists of various functions to perform linear algebra operations and generate random numbers. NumPy is often used along with packages like SciPy and Matplotlib for technical computing.
An n-dimensional (multidimensional) array has a fixed size and contains items of the same type. the contents of the multidimensional array can be accessed and modified by using indexing and slicing the array as desired. For accessing elements of an array we need to first import the library:
import numpy as np
We can use Integer Indexing to access elements of data. We can also perform Slicing to access sub-sequences of data.
[1 2 3 4 5] using positive index :1 using positive index :5 using negative index :5 using negative index :1
[[ 93 95] [ 84 100] [ 99 87]] shape :(3, 2) positive indexing :84 negative indexing :84 slicing using positive indices :[ 95 100 87] slicing using positive indices :[ 95 100 87] slicing using negative indices :[ 95 100 87]
[[[ 0 1 2] [ 3 4 5] [ 6 7 8]] [[ 9 10 11] [12 13 14] [15 16 17]] [[18 19 20] [21 22 23] [24 25 26]]] shape :(3, 3, 3) acessing element :3 acessing elements of a row and a column of an array:[ 3 12 21] accessing sub part of an array :[[ 9 10 11] [12 13 14] [15 16 17]]
- Python | Broadcasting with NumPy Arrays
- Python Lists VS Numpy Arrays
- Python: Operations on Numpy Arrays
- Python | Write multiple files data to master file
- Convert Python List to numpy Arrays
- Python | Convert Numpy Arrays to Tuples
- Indexing Multi-dimensional arrays in Python using NumPy
- Convert Python Nested Lists to Multidimensional NumPy Arrays
- Data type Object (dtype) in NumPy Python
- Python | Accessing Key-value in Dictionary
- Python | Accessing index and value in list
- Accessing Attributes and Methods in Python
- Python | Accessing all elements at given list of indexes
- Python | Accessing nth element from tuples in list
- Python | Accessing variable value from code scope
- Splitting Arrays in NumPy
- Python | Numpy numpy.ndarray.__truediv__()
- Python | Numpy numpy.ndarray.__pos__()
- Python | Numpy numpy.ndarray.__mul__()
- Python | Numpy numpy.ndarray.__sub__()
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to email@example.com. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.