Answers for "numpy replace"

0

numpy replace

import numpy as np
array1 = np.array([2, 2, 2, 0, 2, 0, 2])
print(np.where(array1==0, 1, array1))
# OUTPUT = [2 2 2 1 2 1 2]
Posted by: Guest on February-21-2022

Python Answers by Framework

Browse Popular Code Answers by Language