[SciPy-User] delete rows and columns

Lee lchaplin13@gmail....
Wed Mar 14 05:16:09 CDT 2012


Hi all,

first time here, sorry if I am not posting in the right group.
I am trying to run the below example from numpy docs:

import numpy as np
print np.version.version #1.6.1 (win7-64, py2.6)

a = np.array([0, 10, 20, 30, 40])
np.delete(a, [2,4]) # remove a[2] and a[4]
print a
a = np.arange(16).reshape(4,4)
print a
np.delete(a, np.s_[1:3], axis=0) # remove rows 1 and 2
print a
np.delete(a, np.s_[1:3], axis=1) # remove columns 1 and 2
print a

Basically I am trying to delete some column/rows from an array or a
matrix.
It seems that delete doesn't work I expect (and advertised). Am I
missing something?

Thanks,
Lee


More information about the SciPy-User mailing list