总结自nndl_exercise

Numpy导入

import numpy as np

数组/矩阵的创建

a=np.array([1,2,3])
b=np.array([[1,2],[3,4]])
c=np.zeros((1,2),dtype=int) ##全0矩阵
d=np.ones((1,2)) ##全1矩阵
e=np.identity(4) ##4*4单位矩阵
f=np.random.random((3,2)) ##3*2随机矩阵

属性功能

type(a) ##类型
a.dtype ##数据类型
a.shape ##形状
a[0]
a[0,0] ##元素

##加减乘除,对应位置的元素做运算
a+b
np.add(a,b)
a*b
np.multiply(a,b)
a-b
np.subtract(a,b)
a/b
np.divide(a,b)

##矩阵乘法
np.dot(a,b)

##取a的倒数第二行和最后一行
b=a[-2:,:]

##开方
np.sqrt(a)
a**(1/2)

##求e
np.exp(a)

##求和
np.sum(a)
##算每一列和
np.sum(a,axis=0)
##算每一行和
np.sum(a,axis=1)

##求平均数
np.mean(a)
##算每一列平均数
np.mean(a,axis=0)
##算每一行平均数
np.mean(a,axis=1)

##转置
a.T

##值最大的下标
np.argmax(a)
##每一列值最大的下标
np.argmax(a,axis=0)
##每一行值最大的下标
np.argmax(a,axis=1)

##0~3pi,步长0.1的数组
x=np.arange(0,3*np.pi,0.1)
##sin
np.sin(x)
##cos
np.cos(x)

注记

np.nan不可比较大小,返回false

最新文章

  1. jprofiler_监控远程linux服务器的JVM进程(实践)
  2. oslo.messaging 1.8.0 bug fix and blueprint
  3. HBase概念学习(十)HBase与MongDB等NoSQL数据库对照
  4. Row Border in DataGrid 表格边框
  5. TypeScript学习指南第二章--接口(Interface)
  6. gitlab hooks
  7. discuz门户文章页面模板修改
  8. day16<集合框架+>
  9. 正则表达式&常用JS校验
  10. 树链剖分( 洛谷P3384 )
  11. Java 常用List集合使用场景分析
  12. HDU 5950 - Recursive sequence - [矩阵快速幂加速递推][2016ACM/ICPC亚洲区沈阳站 Problem C]
  13. 配置nginx1.8支持thinkPHP3.2 pathinfo模式
  14. centos 7使用docker安装lnmp和redis环境
  15. go语言之进阶篇方法的继承
  16. Definitaion of 'utsname' must be imported from module 'Darwin.POSIX.sys.utsname' before it is required
  17. mapreduce 只使用Mapper往多个hbase表中写数据
  18. Failure to transfer org.springframework.boot:spring-boot-starter-parent:pom:2.0.1.RELEASE from https://repo.maven.apache.org/maven2 was cached in the local repository, resolution will not be reattempt
  19. .net core iis 502.5
  20. Leetcode题库——16.最接近的三数之和

热门文章

  1. wcf Origin
  2. 深入分析CAS
  3. VBA For Each循环
  4. iOS - 性能优化:Instruments使用简介
  5. table固定宽度与自动宽度
  6. vue 做的tabBar组件
  7. 三种JS截取字符串方法
  8. 50个Sql语句实战
  9. Wireshark解密HTTPS数据流
  10. Linux 非互联网环境安装依赖包