numpy.ma.MaskedArray class
是ndarray的子類,旨在處理缺少數據的數字數組。借助於Numpy MaskedArray .__ itruediv__,我們可以指定在MaskedArray.__itruediv__()方法中作為參數提供的特定值。
用法: numpy.MaskedArray.__itruediv__(other)
返回:真正將自己除以其他就地。
範例1:
在此示例中,我們可以看到數組中的每個元素都用方法MaskedArray.__itruediv__()中作為參數給出的值進行除法。
# import the important module in python
import numpy as np
# make an array with numpy
gfg = np.ma.array([1, 2.5, 3, 4.8, 5])
# applying MaskedArray.__itruediv__() method
print(gfg.__itruediv__(2))
輸出:
[ 0.5 1.25 1.5 2.4 2.5 ]
範例2:
# import the important module in python
import numpy as np
# make an array with numpy
gfg = np.ma.array([[1, 2, 3, 4.45, 5],
[6, 5.5, 4, 3, 2.62]])
# applying MaskedArray.__itruediv__() method
print(gfg.__itruediv__(5))
輸出:
[[ 0.2 0.4 0.6 0.89 1. ] [ 1.2 1.1 0.8 0.6 0.524]]
相關用法
- Python Numpy numpy.ndarray.__lshift__()用法及代碼示例
- Python Numpy numpy.ndarray.__xor__()用法及代碼示例
- Python Numpy numpy.ndarray.__and__()用法及代碼示例
- Python Numpy numpy.ndarray.__rshift__()用法及代碼示例
- Python Numpy numpy.ndarray.__add__()用法及代碼示例
- Python Numpy numpy.ndarray.__sub__()用法及代碼示例
- Python Numpy numpy.ndarray.__mul__()用法及代碼示例
- Python Numpy numpy.ndarray.__truediv__()用法及代碼示例
- Python Numpy numpy.ndarray.__or__()用法及代碼示例
- Python Numpy numpy.ndarray.__pos__()用法及代碼示例
- Python Numpy numpy.ndarray.__iadd__()用法及代碼示例
- Python Numpy numpy.ndarray.__pow__()用法及代碼示例
- Python Numpy numpy.ndarray.__invert__()用法及代碼示例
- Python Numpy numpy.ndarray.__mod__()用法及代碼示例
- Python Numpy numpy.ndarray.__imul__()用法及代碼示例
注:本文由純淨天空篩選整理自Shivam_k大神的英文原創作品 Python | Numpy MaskedArray.__itruediv__。非經特殊聲明,原始代碼版權歸原作者所有,本譯文未經允許或授權,請勿轉載或複製。