[Numpy-discussion] Usage of numpy.where and pylab.find with strings
Ariel Rokem
arokem@berkeley....
Mon Jan 26 13:48:58 CST 2009
Hi - I am trying to find a string in a list with strings and have come
across the following state of affairs:
In [228]: subjects
Out[228]:
['KAA',
'CCS',
'EJS',
'MNM',
'JHS',
'LJL',
'DVA',
'FCL',
'CNC',
'KFM',
'APM',
'GMC']
In [229]: subjects[0]
Out[229]: 'KAA'
In [230]: subjects[0] == 'KAA'
Out[230]: True
In [231]: np.where(subjects == 'KAA')
Out[231]: ()
In [232]: pylab.find(subjects == 'KAA')
Out[232]: array([], dtype=int32)
It doesn't seem to matter if I make the list into an array:
In [233]: np.array(subjects)
Out[233]:
array(['KAA', 'CCS', 'EJS', 'MNM', 'JHS', 'LJL', 'DVA', 'FCL', 'CNC',
'KFM', 'APM', 'GMC'],
dtype='|S3')
In [234]: pylab.find(subjects == 'KAA')
Out[234]: array([], dtype=int32)
In [235]: np.where(subjects == 'KAA')
Out[235]: ()
What am I doing wrong? What does it mean that the dtype is IS3?
Thanks a bunch --
Ariel
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://projects.scipy.org/pipermail/numpy-discussion/attachments/20090126/f10433b9/attachment.html
More information about the Numpy-discussion
mailing list