How to remove every other element of an array in python? (The inverse of np.repeat()?) -
if have array x, , np.repeat(x,2)
, i'm practically duplicating array.
>>> x = np.array([1,2,3,4]) >>> np.repeat(x, 2) array([1, 1, 2, 2, 3, 3, 4, 4])
how can opposite end original array?
it should work random array y:
>>> y = np.array([1,7,9,2,2,8,5,3,4])
how can delete every other element end following?
array([7, 2, 8, 3])
y[1::2]
should job. here second element chosen indexing 1, , taken @ interval of 2.
Comments
Post a Comment