Numpy 的 subtract(~)
方法接受兩個數組並執行逐元素減法。
警告
選擇直接減法(即 arr_one - arr_two
)
除非您需要該方法的第二個和第三個參數,否則請選擇直接使用 -
運算符來提高性能。
參數
1. x1
| array-like
第一個輸入數組。
2. x2
| array-like
第二個輸入數組。
3. out
| Numpy array
| optional
您可以將結果放入 out
指定的數組中,而不是創建新數組。
4. where
| boolean
的array
| optional
標記為 False 的值將被忽略,即它們的原始值將未被初始化。如果您指定了 out
參數,則行為會略有不同 - 原始值將保持不變。
返回值
如果 a
是標量,則返回標量,否則返回 Numpy 數組。
例子
基本用法
a = np.array([1,2,3])
b = np.array([6,5,4])
np.subtract(a,b)
array([-5, -3, -1])
相關用法
- Python Tableau subscriptions.delete用法及代碼示例
- Python subprocess.run用法及代碼示例
- Python subprocess.Popen用法及代碼示例
- Python Tableau subscription.get_by_id用法及代碼示例
- Python subprocess.check_output用法及代碼示例
- Python subprocess.getstatusoutput用法及代碼示例
- Python Tableau subscription.update用法及代碼示例
- Python subprocess.Popen.communicate用法及代碼示例
- Python Tableau subscription.create用法及代碼示例
- Python super()用法及代碼示例
- Python NumPy sum方法用法及代碼示例
- Python sum()用法及代碼示例
- Python super用法及代碼示例
- Python sum方法用法及代碼示例
- Python sklearn.cluster.MiniBatchKMeans用法及代碼示例
- Python NumPy squeeze方法用法及代碼示例
- Python scipy.ndimage.binary_opening用法及代碼示例
- Python scipy.signal.windows.tukey用法及代碼示例
- Python scipy.stats.mood用法及代碼示例
- Python str.isidentifier用法及代碼示例
- Python sklearn.metrics.fbeta_score用法及代碼示例
- Python scipy.fft.ihfftn用法及代碼示例
- Python scipy.stats.normaltest用法及代碼示例
- Python scipy.ndimage.convolve1d用法及代碼示例
- Python scipy.stats.arcsine用法及代碼示例
注:本文由純淨天空篩選整理自Isshin Inada大神的英文原創作品 NumPy | subtract method。非經特殊聲明,原始代碼版權歸原作者所有,本譯文未經允許或授權,請勿轉載或複製。