南沙群岛的资料,李妍杜,pvc瑜伽垫
# -*- coding: utf-8 -*- """ python version: 3.5 created on thu may 11 17:00:47 2017 e-mail: eric2014_lv@sjtu.edu.cn @author: didilv """ # 数学的函数 import numpy as np x = np.array([[1,2],[3,4]]) # 计算所有的数组值 print(np.sum(x)) # 计算矩阵的列 print(np.sum(x, axis=0)) # 计算矩阵的行 print(np.sum(x, axis=1)) # python还是跟matlab有关的,是按列排序的。 # 当然可以有更多的延伸,都是数学的其他函数 # https://docs.scipy.org/doc/numpy/reference/routines.math.html x = np.array([[1,2], [3,4]]) print(x) # 输出 "[[1 2] # [3 4]]" print(x.t) # 输出 "[[1 3] # [2 4]]" # note that taking the transpose of a rank 1 array does nothing: v = np.array([1,2,3]) print(v) # 输出 "[1 2 3]" print(v.t) # 输出 "[1 2 3]" 数组还是数组没有列的概念啊! # 更多的延伸,类似reshape之类的,可以详情看以下链接 # https://docs.scipy.org/doc/numpy/reference/routines.array-manipulation.html
如对本文有疑问,请在下面进行留言讨论,广大热心网友会与你互动!! 点击进行留言回复
python求numpy中array按列非零元素的平均值案例
网友评论