I use Python with numpy
.
I have a numpy array of indexes a
:
>>> a
array([[5, 7],
[12, 18],
[20, 29]])
>>> type(a)
<type 'numpy.ndarray'>
I have a numpy array of indexes b
:
>>> b
array([[2, 4],
[8, 11],
[33, 35]])
>>> type(b)
<type 'numpy.ndarray'>
I need to join an array a
with an array b
:
a
+ b
=> [2, 4] [5, 7] [8, 11] [12, 18] [20, 29] [33, 35]
=> a
and b
there are arrays of indexes => [2, 18] [20, 29] [33, 35]
( indexes ([2, 4][5, 7][8, 11][12, 18])
go sequentially
=> 2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18
=> [2, 18]
)
For this example:
>>> out_c
array([[2, 18],
[20, 29],
[33, 35]])
Can someone please suggest, how do I get out_c
?
Update: @Geoff suggested solution python union of multiple ranges. Whether this solution the fastest and best in large data arrays?