May-18-2017, 10:26 AM

Good day,

I'm fairly new to Python. I have generated a list and want to rearrange it. I want to know what's the best way to go about doing that — should I use indices or a numpy function?

This is a portion of my 24 by 24 grid that contains 576 entries.

['-19.2740144', '-17.9460128', '-18.8874128', '-22.9789464', '-27.8428464'] This is the data set with only 5 entries.

1. Is this the right format to manipulate the numbers? Should I remove the quotation marks using 'strip'?

2. I want to keep the first entry, then reverse the order of the indices, so instead of having 1, 2, 3, 4, 5, I would have 1, 5, 4, 3, 2. For a set of 24 numbers in the list.

3. There's 24 sets of 24. I want to perform strategy 2, then conduct the same procedure on the global list of 576, which means after rearranging I would have the first set of 24, then the 24th set, 23rd set and so on.

These are some of the things I've tried

I'm fairly new to Python. I have generated a list and want to rearrange it. I want to know what's the best way to go about doing that — should I use indices or a numpy function?

This is a portion of my 24 by 24 grid that contains 576 entries.

['-19.2740144', '-17.9460128', '-18.8874128', '-22.9789464', '-27.8428464'] This is the data set with only 5 entries.

1. Is this the right format to manipulate the numbers? Should I remove the quotation marks using 'strip'?

2. I want to keep the first entry, then reverse the order of the indices, so instead of having 1, 2, 3, 4, 5, I would have 1, 5, 4, 3, 2. For a set of 24 numbers in the list.

3. There's 24 sets of 24. I want to perform strategy 2, then conduct the same procedure on the global list of 576, which means after rearranging I would have the first set of 24, then the 24th set, 23rd set and so on.

These are some of the things I've tried

F=open('tranform.txt','r+') for line in F for index in xrange(23,0,1): print index *** An example I saw that could be worth using — Would I have to modify definition of the sorted? *** def get_list_indices(ls): indices = {} for n, i in enumerate(ls): try: indices[i].append(n) except KeyError: indices[i] = [n] return [i[1] for i in sorted(indices.items(), reverse=True)] #test_list = [4, 1, 4, 8, 5, 13, 2, 4, 3, 7, 14, 4, 4, 9, 12, 1, 6, 14, 10, 8, 6, 4, 11, 1, 2, 11, 3, 9] #print(get_list_indices(list))Thanks for any help!