Reputation: 1301
Am trying to create a groups from the array by target index
for example this my Array
Am trying to target index [1]
of each child of the data array
data = [('0', 'COL1', 'date'),('1', 'COL2', 'date'), ('2', 'COL1', 'date'), ('3', 'COL3', 'date') , ('4', 'COL1', 'date'),('6', 'COL2', 'date')]
expected output is
[[('0', 'COL1', 'date'),('2', 'COL1', 'date'),('4', 'COL1', 'date')],[('1', 'COL2', 'date'),('6', 'COL2', 'date')],[('3', 'COL3', 'date')]]
Thank you any help will appreciated!
Upvotes: 0
Views: 82
Reputation: 104
import numpy as np
data = np.array(data)
data[data[:,1].argsort()]
Upvotes: 1