python - Numpy, masking and sklearn clustering -
i having issue modifying 3d 2d in order supply bandwidth function mean shift calculation. query db data in 1d array of values , set of idÅ› belong these values - me later identify sources. prior calculation add 1 more dimension ensure calculation go right , of these results being kept in 3d array. need supply 2d containing value , 0 calculating function, having trouble constructing 2d compressed (without thrid value describing id) array that. know how using numpy , not having separate list containing id's?
source array:
[(2.819999933242798, 0.0, 16383) (3.75, 0.0, 16384) (3.75, 0.0, 16385)]
array after has been masked:
[(2.819999933242798, 0.0, --) (3.75, 0.0, --) (3.75, 0.0, --)]
array needs be:
[(2.819999933242798, 0.0) (3.75, 0.0) (3.75, 0.0)]
cheers
you first convert numpy array:
h=[(2.819999933242798, 0.0, 16383), (3.75, 0.0, 16384) , (3.75, 0.0, 16385)] a=np.array(h)
and columns want:
a[:,0:2]
gives:
array([[ 2.81999993, 0. ], [ 3.75 , 0. ], [ 3.75 , 0. ]])
or a[:,:-1]
suggested @brenbarn in comments
Comments
Post a Comment