湖上湖
要将所有 < 0.5 的索引归零,>>> x3 = np.random.rand(5, 5)>>> x3array([[0.50866152, 0.56821455, 0.88531855, 0.36596337, 0.08705278], [0.96215686, 0.19553668, 0.15948972, 0.20486815, 0.74759719], [0.36269356, 0.54718917, 0.66196524, 0.82380099, 0.77739482], [0.0431448 , 0.47664036, 0.80188153, 0.8099637 , 0.65258638], [0.84862179, 0.22976325, 0.03508076, 0.72360136, 0.76835819]])>>> x3[x3 < .5] = 0>>> x3array([[0.50866152, 0.56821455, 0.88531855, 0. , 0. ], [0.96215686, 0. , 0. , 0. , 0.74759719], [0. , 0.54718917, 0.66196524, 0.82380099, 0.77739482], [0. , 0. , 0.80188153, 0.8099637 , 0.65258638], [0.84862179, 0. , 0. , 0.72360136, 0.76835819]])