使用另一个数组中的一些元素从另一个数组中创建一个数组,其他元素填充为零

时间:2020-01-23 18:19:24

标签: python numpy

我有一个数组

(?<=\w\b )([ 0-9]*)
            ^ additional space

所以

np.random.seed(42)
x = np.random.rand(3, 3)

我想从该数组创建另一个元素,仅使用x中的一些元素,并填充零个其他元素,例如,如果我想要元素array([[0.37454012, 0.95071431, 0.73199394], [0.59865848, 0.15601864, 0.15599452], [0.05808361, 0.86617615, 0.60111501]]) ,我将得到一个数组

x[1::2,::2]

0 个答案:

没有答案