I am trying to sort an array and separate it in python.
Example:
I have an data file like this that I will import:
x y z
1 3 83
2 4 38
8 1 98
3 87 93
4 1 73
1 3 67
9 9 18
1 4 83
9 3 93
8 2 47
I want it to first look like this:
x y z
1 3 83
1 3 67
1 4 83
2 4 38
3 87 93
4 1 73
8 1 98
8 2 47
9 9 18
9 3 93
So the x column is in ascending order, followed by the y column.
And then finally I want to build an array out of these arrays? Can I do that?
So I have:
array[0] = [[1, 3, 83],[1, 3, 67],[1, 4, 83]]
array[1] = [[2, 4, 38]]
array[2] = [[3, 87, 93]]
array[3] = [[4, 1, 73]]
array[4] = [[8, 1, 98],[8,2,47]]
and so on...
Starting out:
import numpy as np
import matplotlib.pyplot as plt
data_file_name = 'whatever.dat'
data=np.loadtxt(data_file_name)