国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 學(xué)院 > 開發(fā)設(shè)計(jì) > 正文

np.where

2019-11-06 08:48:04
字體:
供稿:網(wǎng)友
有時(shí)間過來整理numpy.where(condition[,x,y])

Return elements, either from x or y, depending on condition.

If only condition is given, return condition.nonzero().

Parameters:

condition : array_like, bool

When True, yield x, otherwise yield y.

x, y : array_like, optional

Values from which to choose. x and y need to have the sameshape as condition.

Returns:

out : ndarray or tuple of ndarrays

If both x and y are specified, the output array containselements ofx wherecondition is True, and elements fromy elsewhere.

If only condition is given, return the tuplecondition.nonzero(), the indices wherecondition is True.

[xv if c else yv for (c,xv,yv) in zip(condition,x,y)]
>>> np.where([[True, False], [True, True]],...          [[1, 2], [3, 4]],...          [[9, 8], [7, 6]])array([[1, 8],       [3, 4]])
>>> np.where([[0, 1], [1, 0]])(array([0, 1]), array([1, 0]))
>>> x = np.arange(9.).reshape(3, 3)>>> np.where( x > 5 )(array([2, 2, 2]), array([0, 1, 2]))>>> x[np.where( x > 3.0 )]               # Note: result is 1D.array([ 4.,  5.,  6.,  7.,  8.])>>> np.where(x < 5, x, -1)               # Note: broadcasting.array([[ 0.,  1.,  2.],       [ 3.,  4., -1.],       [-1., -1., -1.]])

Find the indices of elements of x that are in goodvalues.

>>> goodvalues = [3, 4, 7]>>> ix = np.in1d(x.ravel(), goodvalues).reshape(x.shape)>>> ixarray([[False, False, False],       [ True,  True, False],       [False,  True, False]], dtype=bool)>>> np.where(ix)(array([1, 1, 2]), array([0, 1, 1]))
發(fā)表評(píng)論 共有條評(píng)論
用戶名: 密碼:
驗(yàn)證碼: 匿名發(fā)表
主站蜘蛛池模板: 乌拉特后旗| 银川市| 友谊县| 衡阳县| 家居| 岗巴县| 资兴市| 新邵县| 扶沟县| 郧西县| 邓州市| 浦北县| 龙陵县| 宁陕县| 德清县| 壶关县| 关岭| 上林县| 毕节市| 长宁县| 茶陵县| 临沧市| 赣州市| 弥渡县| 文化| 宝坻区| 五原县| 东莞市| 社会| 宜昌市| 留坝县| 阳朔县| 独山县| 渝中区| 板桥市| 莒南县| 密云县| 龙陵县| 肃南| 化州市| 聂拉木县|