“Substitua os valores da matriz python” Respostas de código

Substitua os valores da matriz python

>>> A = np.array((1,7,3,8,4,9,1))
>>> np.where(A>4,1,A)
array([1, 1, 3, 1, 4, 1, 1])
Horrible Hoopoe

Substitua os valores da matriz python

>>> import numpy as np
   >>> M = np.arange(10)
   >>> M
   array([0, 1, 2, 3, 4, 5, 6, 7, 8, 9])
   >>> M[(M > 2) & (M < 7)] = -1
   >>> M
   array([ 0,  1,  2, -1, -1, -1, -1,  7,  8,  9])
Horrible Hoopoe

Respostas semelhantes a “Substitua os valores da matriz python”

Perguntas semelhantes a “Substitua os valores da matriz python”

Mais respostas relacionadas para “Substitua os valores da matriz python” em Python

Procure respostas de código populares por idioma

Procurar outros idiomas de código