How do you choose a pricing plan separately for each item?

choose treats each integer as a candidate-array number and reads that candidate at the corresponding position.

numpy.choose in practice

Two items use plans zero and one respectively. An index identifies the price sheet for an item. The default mode rejects an index outside the set of sheets.

import numpy as np
np.choose([0,1], [[10,20],[12,16]])

Result [10, 16]

中文

怎样从多个报价方案中逐项选价?

choose 把每个位置的整数当作候选数组的编号,并读取该候选在对应位置的值。

numpy.choose 算例

两件商品分别走方案零和一。编号表示选哪张报价单,而非报价单中的行号;默认模式会拒绝越界编号。

import numpy as np
np.choose([0,1], [[10,20],[12,16]])

结果 [10, 16]

References / 参考来源

Keep reading / 继续阅读