zoukankan      html  css  js  c++  java
  • Python学习(五)Numpy通用函数汇总

    参考资料:

    https://github.com/lijin-THU/notes-python(相应实体书为:《自学Python——编程基础、科学计算及数据分析》)

    Numpy通用函数汇总

    import numpy as np

    1. 三角函数

    • sin(x)
    • cos(x)
    • tan(x)
    • sinh(x)
    • conh(x)
    • tanh(x)
    • arccos(x)
    • arctan(x)
    • arcsin(x)
    • arccosh(x)
    • arctanh(x)
    • arcsinh(x)
    • arctan2(x,y)  //返回 arctan(x/y)

    2. 向量操作

    • dot(x,y)
    • inner(x,y)
    • cross(x,y)
    • vdot(x,y)
    • outer(x,y)
    • kron(x,y)
    • tensordot(x,y[,axis])

    3. 其他操作

    • exp(x)
    • log(x)
    • log10(x)
    • sqrt(x)
    • absolute(x)
    • conjugate(x)
    • negative(x)
    • ceil(x)
    • floor(x)
    • fabs(x)
    • hypot(x)  //返回对应点 (x,y) 到原点的距离
    • fmod(x)
    • maximum(x,y)
    • minimum(x,y)
    1 x = np.array([1,2,3])
    2 y = np.array([4,5,6])
    3 np.hypot(x,y)  #array([ 4.12310563,  5.38516481,  6.70820393])

    4. 类型处理

    • iscomplexobj
    • iscomplex
    • isrealobj
    • isreal
    • imag
    • real
    • real_if_close
    • isscalar
    • isneginf  //-np.inf 负无穷
    • isposinf
    • isinf  //检查是否为无穷  np.inf 正无穷
    • isfinite
    • isnan  // 0/0 会得到 nan,非0值除以0会得到无穷  np.nan 非法值
    • nan_to_num
    • common_type
    • typename

    注:nan 与任何数进行比较都是 False,想要找出 nan 值需要使用 isnan()

    5. 修改形状

    • atleast_1d
    • atleast_2d
    • atleast_3d
    • expand_dims
    • apply_over_axes
    • apply_along_axis
    • hstack
    • vstack
    • dstack
    • column_stack
    • hsplit
    • vsplit
    • dsplit
    • split
    • squeeze

    6. 其他有用函数

    • fix
    • mod
    • amax
    • amin
    • ptp
    • sum
    • cumsum
    • prod
    • cumprod
    • diff
    • angle
    • unwrap
    • sort_complex
    • trim_zeros
    • fliplr
    • flipud
    • rot90
    • diag
    • eye
    • select
    • extract
    • insert
    • roots
    • poly
    • any
    • all
    • disp
    • unique
    • nansum
    • nanmax
    • nanargmax
    • nanargmin
    • nanmin

    注:nan 开头的函数会进行相应的操作,但是忽略 nan 值

  • 相关阅读:
    C# LUA 闭包
    string与stringBuilder的效率与内存占用实测
    U3D assetbundle打包
    U3D assetbundle加载
    U3D临时文件GICache巨大
    Unity 协程Coroutine综合测试
    U3D协程Coroutine之WWW与Update()的并行测试
    U3D5.3.5f Monodevelop 仅支持到.NET 3.5
    安卓android杀不死进程,保护,双进程守护,驻留,Marsdaemon,保活
    html 音乐 QQ播放器 外链 代码 播放器 外链 代码
  • 原文地址:https://www.cnblogs.com/hg-love-dfc/p/10289606.html
Copyright © 2011-2022 走看看