Pruthvi Patel

Pruthvi Patel

  • NA
  • 129
  • 23.5k

How to do this type of insert in 2d array in python?

Mar 23 2017 12:56 AM
I have 2D array where y is sorted and unique.so insert operation should be based on y.
 x y
 0.012396.470
 0.017    401.480
 0.028406.490
 0.032411.500 
 0.038416.510 
 0.043421.520 
 0.046426.530 
 0.051431.540 
 0.050436.540 
 0.050441.550 
 and now i have another inputed2darray
 0.030408.505 
 0.043421.520 
 0.050430.050 
 0.047438.540 
then output array should be like this
 x y
 0.012 396.470
 0.017  410.480
 0.028 406.490
 0.030 408.505
 0.032 411.500
 0.038 416.510 
 0.043 421.520
 0.046 426.530 
 0.050 430.050
 0.051 431.540
 0.050 436.540
 0.047 438.540
 0.050 441.550
 
 and also return the index of inserted and non inserted(if the element is present in the list then not insert) element
 outputindexarr=[3,6,8,11] 
 yellow highlighted:was not present in the given 2d array so it was inserted in the outputarray
green highlighted: was present in the given 2d array so it was inserted in the outputarray.