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 值

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM