Numpy基础
GJ_WL
这个作者很懒,什么都没留下…
展开
-
N维数组_4_数组运算
import numpy as np 1.数组与数的运算 arr = np.array([[1, 2, 3, 2, 1, 4], [5, 6, 1, 2, 3, 1]]) arr + 1 arr / 2 array([[0.5, 1. , 1.5, 1. , 0.5, 2. ], [2.5, 3. , 0.5, 1. , 1.5, 0.5]]) # 可以对比python列表的运算,看出区别 a = [1, 2, 3, 4, 5] a * 3 [1, 2, 3, 4, 5, 1, 2,原创 2020-08-28 12:08:44 · 307 阅读 · 0 评论 -
N维数组_3_ndarray运算
import numpy as np 1.逻辑运算 # 生成10名同学,5门功课的数据 score = np.random.randint(40, 100, [10, 5]) score array([[98, 47, 44, 77, 43], [46, 78, 52, 54, 87], [64, 78, 67, 75, 59], [59, 72, 78, 59, 50], [92, 55, 56, 81, 84], [54, 94,原创 2020-08-28 12:07:48 · 223 阅读 · 0 评论 -
N维数组_2_ndarray基本操作
import numpy as np import matplotlib.pyplot as plt 1.生成数组的方法 1.1 生成0和1的数组 # np.ones(shape, dtype) # np.ones_like(a, dtype) # np.zeros(shape, dtype) # np.zeros_like(a, dtype) one = np.ones([4, 8], 'float64') one array([[1., 1., 1., 1., 1., 1., 1., 1.],原创 2020-08-28 12:05:15 · 395 阅读 · 0 评论 -
N维数组_1_ndarray介绍
import numpy as np import random import time 1.Numpy中ndarray介绍 score = np.array( [[80, 89, 86, 67, 79], [78, 97, 89, 67, 81], [90, 94, 78, 67, 74], [91, 91, 90, 67, 69], [76, 87, 75, 67, 86], [70, 79, 84, 67, 84], [94, 92原创 2020-08-28 12:01:17 · 399 阅读 · 0 评论
分享