Say I got an array of str
:
['12.5', '7', '45', '\n', '13.7', '52', '34.3', '\n']
And I want to split it by value, in this case by '\n'
, so it becomes:
[['12.5', '7', '45'],
['13.7', '52', '34.3']]
I don't want to enumerate every element since it's time consuming when input has a large scale. So I wonder if there are some functions or python tricks that can easily achieve this.
P.S.
I've saw this question but it doesn't help much. Mainly because I don't quite understand how np.where()
works with np.split()
, also because I'm working on str
type.
Another thing might be helpful is that my final goal is to generate a matrix of numbers (maybe float
type), so I'll also be glad to know if there's any numpy function can do this.