numpy具有以下三大特点
拥有n维数组对象
拥有广播功能
拥有各种科学计算API
2、安装numpy
numpy是一个python库,所以使用python包管理工具pip或者conda都可以安装
pip...3,4)))
'''
输出:
array([[1, 2],
[3, 4]])
'''
使用arange函数创建一维数字数组,用法类似python的range函数
import numpy...import numpy as np
# 创建一维数组
x1 = np.array([1,2,3])
# 返回维度值
x1.ndim
'''
输出:1
'''
# 创建二维数组
x2 = np.array...x2 = np.array([[1,2,3],[4,5,6]])
# 将x2转换为三维数组,并且自定义每个轴的元素数量
x2.reshape(1,2,3)
'''
输出:
array([[[1, 2,...x2 = np.array([[1,2,3],[4,5,6]])
# 将x2转换为三维数组,并且自定义每个轴的元素数量
x2.resize((1,2,3))
x2
'''
输出:
array([[[1