I have a list of the following form:
[[0, 5.1, 3.5, 1.4, 0.2],
[0, 4.9, 3.0, 1.4, 0.2],
[0, 4.7, 3.2, 1.3, 0.2],
[1, 4.6, 3.1, 1.5, 0.2],
[1, 5.0, 3.6, 1.4, 0.2],
[1, 5.4, 3.9, 1.7, 0.4],
[1, 4.6, 3.4, 1.4, 0.3]]
I want to slice out the first column and add it as a new element to each row of data (so at each odd position in the list), changing it to the following form:
[[5.1, 3.5, 1.4, 0.2], [0],
[4.9, 3.0, 1.4, 0.2], [0],
[4.7, 3.2, 1.3, 0.2], [0],
[4.6, 3.1, 1.5, 0.2], [1],
[5.0, 3.6, 1.4, 0.2], [1],
[5.4, 3.9, 1.7, 0.4], [1],
[4.6, 3.4, 1.4, 0.3], [1],]
How could I do this?
So far, I have extracted the necessary information in the following ways:
targets = [element[0] for element in dataset]
features = dataset[1:]