this is my numpy.char.array
table = np.char.arrray([['/finance/stocks/overview?symbol=TMIN.NS&exchange=INSE'],
['/finance/stocks/overview?symbol=8KMS.BO&exchange=INB'],
['/finance/stocks/overview?symbol=ADRG.NS&exchange=INSE']],dtype='|S53')
how can i get the below desired output:
out = ['TMIN.NS','8KMS.BO','ADRG.NS']
with table.find(".NS")i can get the index position of .NSin the string. But how can i use this to get to the desired output?
In [69]: table.find(".NS")
Out[69]:
array([[36],
[-1],
[36],
...,
[36],
[36],
[36]])
the reason, simple index based selection does not work is because, the whole string is just single element. The shape of array is (30L,1L)
I can use str or regex on individual string elements to get the desired output, but that will require running a for loop over the array. How can i do this in numpy alone? thanks.
edit_1/ this is how i can get the result though indexing but i cannot do it at the same time on the whole array
table[0][0][32:38]
Out[75]: 'TMIN.N'
7characters? Would they always be followed by that string'/finance/stocks/overview?symbol='?7characters?charfunctions (in this case methods ofchararray) just apply the correspondingstringmethod to each element of the array. They don't speed things up much compared to an explicit loop. I'd suggest apply your own string operation in a list comprehension.