np.ma.masked_array(data, mask=None) 执行以上代码后,输出结果是以下哪一项? importnumpyas np s = np.array([1, 2, 3, -999, 5]) print("【显示】s") print(s) mask = [False, False, False, True, False] # 屏蔽 -999 print("【执行】np.ma.masked_array(s, mask)") print(np.ma.ma...
使用np.ma函数可以非常方便地处理这类问题。 本文将介绍np.ma函数的使用方法,包括创建掩码数组、对掩码数组进行运算、以及处理掩码数组中的缺失值和异常值。 一、创建掩码数组 创建掩码数组的方法很简单,只需要调用np.ma.masked_array()函数即可。该函数接受两个参数:数据数组和掩码数组。 掩码数组是一个与数据数组...
np.ma.masked_where sets .mask to False when there is no masked elements in an array #14650 Closed guziy opened this issue Oct 6, 2019· 6 comments Commentsguziy commented Oct 6, 2019 • edited The problem is that np.ma.masked_where puts a single boolean into the mask field if...
masked_array(data=[1.0, 2.0, --, --, 5.0], mask=[False, False, True, True, False], fill_value=1e+20) 在这个例子中,np.nan和np.inf被屏蔽,用--表示。 4. np.ma.masked_invalid函数返回的结果 该函数返回一个掩码数组(MaskedArray),该数组包含以下属性: ...
a=np.array([3,4,np.nan,8,np.nan])print(a.mean())# nana=np.ma.masked_where(np.isnan(a),a)print(a)# [3.0 4.0 -- 8.0 --]print(a.mean())# 5.0 np.ma.masked_where関数でmasked arrayを作っています。第一引数がマスクのbool型ndarray、第二引数がマスクされる元のndarrayです。
array([[1, 2, 5], [3, 4, 6]]) >>> np.concatenate((a, b), axis=None) array([1, 2, 3, 4, 5, 6]) 1. 2. 3. 4. 5. 6. 7. 8. 9. 10. 11. 数组是MaskedArray时的例子,此函数将不会保留MaskedArray输入的掩码,要保留的话要用ma那个函数。
如果需要使用MaskedArray作为输入,请改用MaskedArray模块中的ma.concatenate函数。 正常的数组例子 1 2 3 4 5 6 7 8 9 10 11 >>> a = np.array([[1, 2], [3, 4]]) >>> b = np.array([[5, 6]]) >>> np.concatenate((a, b), axis=0) array([[1, 2], [3, 4], [5, 6]])...
借助np.ma.mini()方法,我们可以通过使用得到掩码数组的最小值np.ma.mini()方法。 用法:np.ma.mini() 返回:Return the minimum value of masked array. 范例1: 在这个例子中,我们可以通过使用np.ma.mini()方法,我们可以使用此方法获得蒙版数组的最小值。
I have a masked array. If I work on it with np.ma functions, things will be fine, but the equivalent function straight from np will silently ignore and remove the mask! The example below is with hstack, but I get the same problem with vstack, repeat, and probably many other numpy fu...
如果需要使用MaskedArray作为输入,请改用MaskedArray模块中的ma.concatenate函数。 正常的数组例子 1 2 3 4 5 6 7 8 9 10 11 >>> a = np.array([[1, 2], [3, 4]]) >>> b = np.array([[5, 6]]) >>> np.concatenate((a, b), axis=0) array([[1, 2], [3, 4], [5, 6]])...