Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- def subtract_array(full_array, sub_array):
- '''
- Take one numpy array (full array),
- and "remove" another (sub_array) from it.
- e.g. subtract_array([1,1,3,5,5,6,7], [1,5,6])
- returns [1,3,5,7]
- sub_array must be a sub-set of the full_array
- '''
- #For each element, i, in the subarray...
- for i in sub_array:
- #Delete the first instance of i from the full array (but leave other instances)
- full_array = np.delete(full_array, np.where(full_array == i)[0][0])
- return full_array
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement