SoFunction
Updated on 2024-10-29

Specific Use of NumPy Array Properties

I. Important ndarray object properties

causality clarification
The rank, i.e. the number of axes or the number of dimensions
The dimension of the array, for a matrix, n rows and m columns.
The total number of elements in the array, equivalent to the value of n*m in .shape.
The element type of the ndarray object
Size of each element in the ndarray object, in bytes
Memory information for ndarray objects
The real part of an ndarray element
The imaginary part of the ndarray element
The buffer containing the actual array elements. Since the elements are generally fetched by the index of the array, this property is usually not needed.

II. Code Demonstration

import numpy as np

# Create
data = ([[1, 2], [3, 4], [5, 6]])
print('data:', data)
# Rank
print('Rank:', )
# Dimension of the array
print('Dimension of the array:', )
# Total number of array elements
print('Total number of array elements:', )
# ndarray object element types
print('The element type of the ndarray object;', )
# size of each element in the ndarray object, in bytes
print('Size of each element:', )
# ndarray object memory information
print('Memory information:', )
# real part of ndarray element
print('Real part:', )
# The imaginary part of the ndarray element
print('Virtual Ministry:', )
# Buffer for the actual array elements (since elements are generally fetched via the index of the array, this attribute is usually not needed)
print('data:', )

data: [[1 2]
[3 4]
[5 6]]
Rank: 2
Dimension of the array: (3, 2)
Total number of array elements: 6
The element type of the ndarray object; int32
Size of each element: 4
Memory information: C_CONTIGUOUS : True
F_CONTIGUOUS : False
OWNDATA : True
WRITEABLE : True
ALIGNED : True
WRITEBACKIFCOPY : False
UPDATEIFCOPY : False

Substantive part: [[1 2]
[3 4]
[5 6]]
Imaginary part: [[0 0]
[0 0]
[0 0]]
data: <memory at 0x00000240173E4380>

This article on the specific use of NumPy array attributes is introduced to this article, more related to the content of NumPy array attributes, please search for my previous posts or continue to browse the following related articles I hope you will support me in the future more!