本文简要介绍 python 语言中 numpy.ma.resize
的用法。
用法:
ma.resize(x, new_shape)
返回具有指定大小和形状的新掩码数组。
这是屏蔽等效的numpy.resize函数。新数组充满了重复的副本x(按照数据在内存中存储的顺序)。如果x被屏蔽后,新数组将被屏蔽,并且新屏蔽将是旧屏蔽的重复。
例子:
>>> import numpy.ma as ma >>> a = ma.array([[1, 2] ,[3, 4]]) >>> a[0, 1] = ma.masked >>> a masked_array( data=[[1, --], [3, 4]], mask=[[False, True], [False, False]], fill_value=999999) >>> np.resize(a, (3, 3)) masked_array( data=[[1, 2, 3], [4, 1, 2], [3, 4, 1]], mask=False, fill_value=999999) >>> ma.resize(a, (3, 3)) masked_array( data=[[1, --, 3], [4, 1, --], [3, 4, 1]], mask=[[False, True, False], [False, False, True], [False, False, False]], fill_value=999999)
无论输入类型如何,始终返回MaskedArray。
>>> a = np.array([[1, 2] ,[3, 4]]) >>> ma.resize(a, (3, 3)) masked_array( data=[[1, 2, 3], [4, 1, 2], [3, 4, 1]], mask=False, fill_value=999999)
相关用法
- Python numpy ma.row_stack用法及代码示例
- Python numpy ma.ravel用法及代码示例
- Python numpy ma.indices用法及代码示例
- Python numpy ma.zeros用法及代码示例
- Python numpy ma.diff用法及代码示例
- Python numpy ma.mask_rowcols用法及代码示例
- Python numpy ma.where用法及代码示例
- Python numpy ma.zeros_like用法及代码示例
- Python numpy ma.notmasked_contiguous用法及代码示例
- Python numpy ma.concatenate用法及代码示例
- Python numpy ma.apply_along_axis用法及代码示例
- Python numpy ma.compress_rowcols用法及代码示例
- Python numpy ma.vstack用法及代码示例
- Python numpy ma.atleast_3d用法及代码示例
- Python numpy ma.count用法及代码示例
- Python numpy ma.fix_invalid用法及代码示例
- Python numpy ma.mean用法及代码示例
- Python numpy ma.argmax用法及代码示例
- Python numpy ma.empty_like用法及代码示例
- Python numpy ma.hstack用法及代码示例
- Python numpy ma.isMA用法及代码示例
- Python numpy ma.argmin用法及代码示例
- Python numpy ma.asarray用法及代码示例
- Python numpy ma.set_fill_value用法及代码示例
- Python numpy ma.is_mask用法及代码示例
注:本文由纯净天空筛选整理自numpy.org大神的英文原创作品 numpy.ma.resize。非经特殊声明,原始代码版权归原作者所有,本译文未经允许或授权,请勿转载或复制。