numpy.ma.in1d#
- ma.in1d(ar1, ar2, assume_unique=False, invert=False)[source]#
Test whether each element of an array is also present in a second array.
The output is always a masked array. See
numpy.in1d
for more details.We recommend using
isin
instead ofin1d
for new code.See also
isin
Version of this function that preserves the shape of ar1.
numpy.in1d
Equivalent function for ndarrays.
Notes
New in version 1.4.0.
Examples
>>> ar1 = np.ma.array([0, 1, 2, 5, 0]) >>> ar2 = [0, 2] >>> np.ma.in1d(ar1, ar2) masked_array(data=[ True, False, True, False, True], mask=False, fill_value=True)