Movatterモバイル変換


[0]ホーム

URL:


SciPy

numpy.ma.expand_dims

numpy.ma.expand_dims(x,axis)[source]

Expand the shape of an array.

Expands the shape of the array by including a new axis before the onespecified by theaxis parameter. This function behaves the same asnumpy.expand_dims but preserves masked elements.

See also

numpy.expand_dims
Equivalent function in top-level NumPy module.

Examples

>>>importnumpy.maasma>>>x=ma.array([1,2,4])>>>x[1]=ma.masked>>>xmasked_array(data = [1 -- 4],             mask = [False  True False],       fill_value = 999999)>>>np.expand_dims(x,axis=0)array([[1, 2, 4]])>>>ma.expand_dims(x,axis=0)masked_array(data = [[1 -- 4]],             mask = [[False  True False]],       fill_value = 999999)

The same result can be achieved using slicing syntax withnp.newaxis.

>>>x[np.newaxis,:]masked_array(data = [[1 -- 4]],             mask = [[False  True False]],       fill_value = 999999)

Previous topic

numpy.ma.atleast_3d

Next topic

numpy.ma.squeeze

  • © Copyright 2008-2009, The Scipy community.
  • Last updated on Jun 10, 2017.
  • Created usingSphinx 1.5.3.

[8]ページ先頭

©2009-2025 Movatter.jp