I have several sub-arrays within an array. I want to make a new array, where I select the first element of each sub-array using slicing. I have done it using for loop and appending, but wondering how to do it using slicing. Any ideas?
arr = np.array([(1,2),(3,4),(5,6),(7,8),(9,10)])
# Desired Result: arr([1,3,5,7,9])
#Attempt to achieve the desired result using slicing
array_first_elements = arr[0::][0]
# output I get: [1,2]
#To achieve the desired result using for loop
arr_new = np.array([])
for i in arr:
arr_new = np.append(arr = arr_new, values =(i[0])).astype(int)