¡@

Home 

python Programming Glossary: np.where

find and delete from more-dimensional numpy array

http://stackoverflow.com/questions/16839303/find-and-delete-from-more-dimensional-numpy-array

something should work like p_r_colors np.delete p_a_colors np.where np.all p_a_colors p_rem axis 0 0 but I just don't get the axis.. for i in range len p_rem p_r_colors np.delete p_r_colors np.where np.all p_r_colors p_rem i axis 1 0 would work but I am trying..

location of array of values in numpy array

http://stackoverflow.com/questions/17796953/location-of-array-of-values-in-numpy-array

them. To find where these indices happen we plug this into np.where and get the first value of the tuple. Now I don't have a fast.. is one . However this will get the job done np.hstack np.where A values i .all axis 1 0 for i in xrange len values This basically.. multi dimensional case all in one go should be fairly fast np.where np.expand_dims A 1 values.T .all axis 1 .any axis 1 0 share..

Curve fitting in Scipy with 3d data and parameters

http://stackoverflow.com/questions/17934198/curve-fitting-in-scipy-with-3d-data-and-parameters

return res def poiss_err data import numpy as np return np.where np.sqrt H 0. np.sqrt H 2. # H x y hist_data mixed_data mbins..

How to detect a Christmas Tree?

http://stackoverflow.com/questions/20772893/how-to-detect-a-christmas-tree

2 valthr # Find pixels that meet hsv criterion binimg np.where boolidx 255 # Add pixels that meet grayscale brightness criterion.. Add pixels that meet grayscale brightness criterion binimg np.where gryimg monothr 255 # Prepare thresholded points for DBSCAN clustering.. points for DBSCAN clustering algorithm X np.transpose np.where binimg 255 Xslice X nsample len Xslice if nsample maxpoints..

Numpy grouping using itertools.groupby performance

http://stackoverflow.com/questions/4651683/numpy-grouping-using-itertools-groupby-performance

diff np.concatenate 1 np.diff values idx np.concatenate np.where diff 0 len values index np.empty len idx 1 dtype 'u4 u2' index.. np.ones values.shape values.dtype dif 1 np.diff values idx np.where dif 0 vals values idx count np.diff idx share improve this..

Is it possible to specify your own distance function using Scikits.Learn K-Means Clustering?

http://stackoverflow.com/questions/5529625/is-it-possible-to-specify-your-own-distance-function-using-scikits-learn-k-means

break prevdist avdist for jc in range k # 1 pass in C c np.where xtoc jc 0 if len c 0 centres jc X c .mean axis 0 if verbose..

How to create a dynamic array

http://stackoverflow.com/questions/6950456/how-to-create-a-dynamic-array

t_array label array pl.legend pl.subplot 212 pl.plot np.where t_list 2 np.median t_list 0 pl.plot np.where t_array 2 np.median.. 212 pl.plot np.where t_list 2 np.median t_list 0 pl.plot np.where t_array 2 np.median t_array 0 pl.show from the graph the increase..