NumPy_and_NumPy_Arrays
NumPy_and_NumPy_Arrays
What is NumPy?
1|Page
You can check if NumPy is installed successfully by opening a Python
interpreter and trying to import NumPy:
import numpy as np
For Windows-
2|Page
2. Multidimensional: NumPy arrays can have multiple dimensions
(axes). For example, a 1-dimensional array is like a list, a 2-
dimensional array is like a matrix, and a 3-dimensional array is like
a cube of numbers.
The dtype defines the kind of data that can be stored in the ndarray,
such as integers, floats, or strings. The header stores information about
the ndarray, such as its shape and size.
3|Page
NumPy arrays, represented by the ndarray object, form the backbone of
numerical computing in Python. They offer a convenient and efficient
way to work with large datasets, enabling a wide range of mathematical
and scientific operations.
Data Type Objects (dtype): Data type Objects in NumPy define how to
interpret a fixed block of memory corresponding to an array. The
interpretation depends on several factors:
4|Page
1. Type of data: Specifies whether the data is an integer, float, or a
Python object.
4. For structured types: Includes the names of fields, the data type of
each field, and the portion of the memory block occupied by each
field.
5. For subarrays: Specifies the shape and data type of the subarray.
• Copy: If set to true, it creates a new copy of the dtype object. If false,
the result is a reference to the built-in data type object.
Example Code:
Output
int32
The code defines a NumPy data type (int32) using the array-scalar type
constructor and prints the data type.
5|Page