This is my NumPy array:
og_arr = [['5mm', '45"', '300 mm WT', 'Nan'], ['50mm', '3/5"', 'Nan', 'Nan']]
I have written some logic that is able to identify at which index position the mm/inch string starts and this results in the following array.
index_arr = [[1, 2, 4, -1], [2, 3, -1, -1]]
I would like to split og_arr into 2 arrays called values and units based on the index_arr so that I get the following.
# perform some sort of indexing + splitting operation involving og_arr and index_arr
values = [['5', '45', '300', 'Nan'], ['50', '3/5', 'Nan', 'Nan']]
units = [['mm', '"', 'mm WT', ''], ['mm', '"', '', '']]
I have a solution to this problem using a for/while loop, however, I am more interested in finding out if a pure vectorized solution exists for this sort of problem.
index_arr.. there is4in the index where we do not have index4inog_arr(it goes from 0 to 3)index_arrpresents the start index of the units in the string. eg.'300 mm WT'inindex_arris4, which ism, and if the string isNan, then return-1to index