2018-12-18
阅读量:
795
如何numpy中的数组?
NumPy中的数组: NumPy的主要对象是同构多维数组。
- 它是一个元素表(通常是数字),都是相同的类型,由正整数元组索引。
- 在NumPy维度中称为轴。轴数是等级。
- NumPy的数组类称为ndarray。它也被别名数组所知。
示例:
# Python program to demonstrate
# basic array characteristics
import numpy as np
# Creating array object
arr = np.array( [[ 1, 2, 3],
[ 4, 2, 5]] )
# Printing type of arr object
print("Array is of type: ", type(arr))
# Printing array dimensions (axes)
print("No. of dimensions: ", arr.ndim)
# Printing shape of array
print("Shape of array: ", arr.shape)
# Printing size (total number of elements) of array
print("Size of array: ", arr.size)
# Printing type of elements in array
print("Array stores elements of type: ", arr.dtype)
输出:






评论(0)


暂无数据
推荐帖子
0条评论
0条评论
0条评论