NumPy Array: Introduction, Creation, and Usage in Python
A NumPy array is a grid of values, all of the same type, indexed by a tuple of non-negative integers. The number of dimensions is the rank of the array; the shape of an array is a tuple of integers giving the size of the array along each dimension.
Here is an example of creating a NumPy array:
import numpy as np
# Create a 1-dimensional array
arr1 = np.array([1, 2, 3, 4, 5])
# Create a 2-dimensional array
arr2 = np.array([[1, 2, 3], [4, 5, 6], [7, 8, 9]])
# Create a 3-dimensional array
arr3 = np.array([[[1, 2, 3], [4, 5, 6]], [[7, 8, 9], [10, 11, 12]]])
NumPy arrays have many useful functions and methods for performing mathematical operations and manipulating the data. They are widely used in scientific computing and data analysis tasks.
原文地址: http://www.cveoy.top/t/topic/fpvI 著作权归作者所有。请勿转载和采集!