So I have a numpy array A of dimensions (8760,12). Basically all the hours of 12 years. I need to sort each month (730 hours) in each year in the array. I haven't found any way to do it inside the array. So my solution was to take out each month, sort it and then create the entire 2d array again. I was thinking of doing something along the lines of what I have below, but it isn't working.
total=np.zeroes([8760,12])
for j in range(1,12):
for i in range (1,12):
#here i take out every month of every year
month=A[730*(i-1):-730*(12-i),(j-1):-(12-j)]
#here I sort the data
month_sorted=np.sort(month,axis=0,kind='quicksort')
#here I try to add the sorted months back into 1 big array
np.concatenate(total,month_sorted,axis=0)
np.concatenate(total,month_sorted,axis=1)
Concatenate doesn't work on arrays of different sizes.
And I don't really have a way to place the month of year 2 in row 2 of my array. I guess it should be done with indexing idx or iloc or something like that.
EDIT: My values are integers.
The result should be values ordered from low to high for each 730(hours in a month) values per row. So imagine I would have 3 years instead of 12 and 9 hours instead of 8760 hours which have to be sorted each 3 hours instead of each 730 hours. The array looks like this :
[[30,40,10,20,50,60,80,200,100]
[8,20,5,6,8,1,5,3,2]
[520,840,600,525,430,20,1,506,703]]
And should be converted into :
[[10,30,40,20,50,60,80,100,200]
[5,8,20,1,6,8,2,3,5]
[520,600,840,20,430,525,1,506,703]]
So my current code take out the first part 30,40,10 and sorts it as 10,30,40. But the part that I can't solve is how to create the big array again from all the smaller ones in the 2 loops.