Jan-12-2022, 07:18 AM
Commas are missing in your list.
Here after another 2 ways. Note that in your example you've a single row and that's why flatten has been used.
Here after another 2 ways. Note that in your example you've a single row and that's why flatten has been used.
### from a list MyArray = [[1.6727031, 1.5464988, 1.6836944, 1.8492563, 1.968533, 2.2368639, 2.6653275, 2.7314425, 2.8197284, 2.969603, 2.8251243, 2.086564, 2.274447, 2.2914152, 2.2962196, 2.381342 ]] MyArray = np.asarray(MyArray).flatten() Extract = MyArray[-8:] #### from an array MyArray2 = np.array([[1.6727031, 1.5464988, 1.6836944, 1.8492563, 1.968533, 2.2368639, 2.6653275, 2.7314425, 2.8197284, 2.969603, 2.8251243, 2.086564, 2.274447, 2.2914152, 2.2962196, 2.381342 ]]) MyArray2 = MyArray.flatten() Extract2 = MyArray2[-8:]