numpy.where and numpy.piecewise usage

1、numpy.where

  numpy.where parameters:

numpy.where (condition, x, y), namely: the value of x when the condition is satisfied, the value of y when the condition is not satisfied, condition elements must be of type bool array (array) type.

2、numpy.piecewise

  numpy.piecewise parameters:

numpy.piecewise (array, [condition1, condition2], [value1, value2]), namely: when a pass array, condition1 values ​​that satisfy value1, condition2 value2 is satisfied; VALUE1 and may also be passed into the function value2 [function1 , condition2 the], i.e., when executed function1 meet condition1 array of elements, is met performed function2 condition2.

  Data can be used to batch process.

Guess you like

Origin www.cnblogs.com/jason--/p/11567124.html