Numpy常用函数总结

import numpy as np

【1】np.mean(data,axis = 1) #求均值

axis = 1 按行求均值,返回m行1列,axis =0 按列求均值,返回1行m列

官方手册:https://docs.scipy.org/doc/numpy/reference/generated/numpy.mean.html

【2】np.cov(data) #求矩阵的协方差

参数详解见博客:https://blog.youkuaiyun.com/jeffery0207/article/details/83032325

【3】np.argsort()

argsort()函数是将x中的元素从小到大排列,提取其对应的index(索引),然后输出

【4】 arr.T  #求矩阵的转置矩阵,适用于一维、二维转置
【5】np.linalg.svd(afull_matrices=Truecompute_uv=True)  #svd奇异值分解

返回三个矩阵 U,S,V的转置

参数解释:a为数组;

                 full_matrices =True (默认),返回的U,V是(M,M)与(N,N),否则为(M,K)(K,N) 

                 compute_uv=True(默认),返回U,S,V的转置。否则返回一个S。

    官方文档:https://docs.scipy.org/doc/numpy/reference/generated/numpy.linalg.svd.html[]

  【6】np.transpose(a,axes=None) #求矩阵的转置

a为数组,axes 为指定的索引顺序,只针对三维及其以上数组有用。二维默认为None。

三维假设数组大小为:reshape(3,4,2)即3个4*2数组。默认axes = (0,1,2)

当axes = (1,0,2)时,对应的数组的reshape为(4,3,2),即变成了4个3*2的矩阵。       

官方文档:https://docs.scipy.org/doc/numpy-1.15.0/reference/generated/numpy.transpose.html

【7】np.linspace(start, stop, num, endpoint=True, retstep=False, dtype=None) #产生制定大小的数组

参数解释:https://www.cnblogs.com/gengyi/p/9363185.html

【8】np.newaxis()#作用就是在这一位置增加一个一维

          举例:https://blog.youkuaiyun.com/molu_chase/article/details/78619731

                     https://www.jianshu.com/p/78e1e281f698

【9】np.ravel()和np.flatten() #将数组展平

          区别:https://blog.youkuaiyun.com/hanshuobest/article/details/78882425

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

Foneone

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值