np where

Solutions on MaxInterview for np where by the best coders in the world

showing results for - "np where"
Tomas
05 Jul 2018
1>>> a = np.arange(10)
2>>> a
3array([0, 1, 2, 3, 4, 5, 6, 7, 8, 9])
4>>> np.where(a < 5, a, 10*a)
5array([ 0,  1,  2,  3,  4, 50, 60, 70, 80, 90])
6
Javier
11 Oct 2017
1import numpy as np
2
3# Return elements chosen from x or y depending on condition.
4a = np.arange(10) # [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]
5single_where = np.where((a<5),-1,a) # [-1, -1, -1, -1, -1,  5,  6,  7,  8,  9]
6multiple_where = np.where((a<5),-1,np.where((a>5),0,a)) # [-1, -1, -1, -1, -1,  5,  0,  0,  0,  0]
Louann
03 Apr 2020
1In [1]: my_array = arange(10)
2
3In [2]: where((my_array > 3) & (my_array < 7))
4Out[2]: (array([4, 5, 6]),)
Nour
29 Sep 2019
1Parameters:
2condition : When True, yield x, otherwise yield y.
3x, y : Values from which to choose. x, y and condition need to be broadcastable to some shape.
4
5Returns:
6out : [ndarray or tuple of ndarrays] If both x and y are specified, the output array contains elements of x where condition is True, and elements from y elsewhere.
queries leading to this page
np where python 3numpy where functionnpmpy wherenp where x 3cynump wherenp where 28 29 functionpython np where 28 29 5b 5dnp where ornumpy where pythonpython wherenp whichnp ndwherenp wherenumpy where implementationnp where arraynumpy np where syntaxnp where python3np where to listnp where 27np where 28 3d 3d 29np where inside np where where numpynp where syntaxnp where 3d 3dnp where 23pythin np wherenumpy where examplewhere python arraynp where documentationnp which pythonnumpy where functionp where 5b 3a 3a 5dnp where in pythonnp where pythonpandas np where where 28 29np wherenp where axis np where 28a 3c 3 29nuimpy where using and in np wherenumpy array use condition inside 5b 5d inclusion exclusion np where with vector condition pythonwhere 28 29 in pythonnp wheenumpy array where trueusing and or or with np wherenumpy whreerlambda condition np wherenp where with variable value pythonnp where exampleshow to use numpy where in pythonhow to use np wherenumpy where documentationnp where usagehow to use numpy where np where where pythonhow to use np where in pythonhow to use numpy wherenumpy whereinnumpy wherenp where functionnumpy where 1what does np where donp where 22 3d 3d 22np wheernp where pandasnp where 28 29np where findnp where on matrixnp andnp array ifnumpy where 28 29 5b0 5dnp where python listnumpy where examplenumpy conditionuse 22where 22 in numpywirte if in numpy wherenp wherenp where pythonwhere on numpy arraynp whichnp where 28 29 5b 5d 5b 5d in pythonnumpy wherenumpy with conditionpython np where 28 29numpy array 5bcondition 5dusing or in np wherenp where 28 29 in pythonnp 2cwherenumpy where in pythonnp where in numpywhere in pythonor fucntion in np whereuse numpy where to return an arraynumpy np where in pythoncondition in numpy wherenp where in pythnnp where np arraynp where for 2 conditionsnumpy wherewhat does np where 28 29 do 3fnp where 3fcondition numpy araypython wherepython numpy where and where in numpypython np where instore np where in listnp wherenp where functionnumpy where 28 29numpy array wherewhere in python numpywhere 28i 3d 3d i 29where npnpoco where innp where with vectors pythonnp where 28 np where 28 29 numpy wherenp where numpynp array wherenp where 26 pythonnp conditional where 28 29 pythonpython np where examplenp where to listpython numpy wherepython np wherenumpy checking array indices where conditionuse np wherenumpy where functionpython where functionwhere numpycondition numpy wherenp where andnumpy where 28 29np where numpy arraynumpy where documentationhttp 3a 2f 2fnumpy wherenp condition valuesnp where example pythowhere in numpynp where example set valuenp where using andwhere numpy pythonnp whereznumpy where 2awhat is np where in pythonnp where truecondition numpy arraynumpy where 28np where in python numpyand condition in numpy wherenp arg python conditionnumpy find where2d numpy array where condition axis 0np where y 3e 3d 0 1 0np where 5carray 5bnp where 28 29 5d pythonnumpy array where conditionwhere function in python python array np wherepython numpy wherenp where andnumpy wherenp where gives list np wher 28which np pythonnp xherenumpy where arraynumpy array where condition axis 0where 28 29 numpypython np where np where how to usenp andnp where pythonwhere 28 29how to apply np where in pythonnp where without x y where in pythonnp where conditionwhere 28 29 numpynp where 5b0 5dusing np wherenp where python examplenp where numpynp whgerenp where in pythonnp where syntax in pythonwhere function pythonnumpy where 28 29awhere python functionpython np array wherewhere 28 29 pythonnp where numpy examplecondition inside ndarry np pythonhow to use np where functionnp ifnumpy where 1 60np where clausenp where ndnp where with 5 or more clause in pythonnp where where pythonnumpy function wherenp where for pandasa numpy array conditionsnp where examplenp array wherepython np where ornp where 28hunor condition in np wherewhere function in numpypython np where in to np wherenp where function in pythonnumpy where 5cif in array python np wherenp where y 3d 3d1numpy where without conditionwhere example numpynp where array matrixnp where list pythonnumpy np wherenp conditionnumpy condition arrayhow to use np where in numpy array 3awhere 28 29np where examplenumpy where conditionnp where is inor in np wherenp wherenumpy where in pythonnp where