numpy.ma.reshape#
- ma.reshape(a, new_shape, order='C')[原始碼]#
返回一個包含相同資料但具有新形狀的陣列。
請參閱
MaskedArray.reshape
以取得完整文件。參見
範例
重塑 1-D 陣列
>>> a = np.ma.array([1, 2, 3, 4]) >>> np.ma.reshape(a, (2, 2)) masked_array( data=[[1, 2], [3, 4]], mask=False, fill_value=999999)
重塑 2-D 陣列
>>> b = np.ma.array([[1, 2], [3, 4]]) >>> np.ma.reshape(b, (1, 4)) masked_array(data=[[1, 2, 3, 4]], mask=False, fill_value=999999)
重塑具有遮罩的 1-D 陣列
>>> c = np.ma.array([1, 2, 3, 4], mask=[False, True, False, False]) >>> np.ma.reshape(c, (2, 2)) masked_array( data=[[1, --], [3, 4]], mask=[[False, True], [False, False]], fill_value=999999)