Python Forum
Most efficient way of reshaping a list-array structure
Thread Rating:
  • 1 Vote(s) - 5 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Most efficient way of reshaping a list-array structure

I'm dealing with huge data and I'm looking for an efficient way to reshape my list of arrays. Here is my solution which I find to be slow
#x is an input of shape [file,measurement, array(n,r)], i.e.
#len(x) returns file
#len(x[0]) returns measurement
#x[0][0].shape returns (n,r)
the output I require:
#new_x is a list of arrays, its shape is [file*measurement*n, array(r)]
I'm using the following code:

for ii in range(len(x)):
    for jj in range(len(x[0])):
        for kk in range(len(x[0][0])):
Is there a more efficient way?
Thank you for your help.
What about
for xi in x:
    for xij in xi:
Much faster, thank you!

Possibly Related Threads…
Thread Author Replies Views Last Post
  LIST or ARRAY Comparison and change of value nio74maz 0 483 Dec-21-2020, 05:52 PM
Last Post: nio74maz
  I there a more efficient way of printing ? Capitaine_Flam 7 1,018 Dec-01-2020, 10:37 AM
Last Post: buran
  2d Array adds last element to entire list waiteup 2 581 Nov-19-2020, 08:25 PM
Last Post: bowlofred
  trouble with list array Milfredo 2 736 Sep-16-2020, 12:07 AM
Last Post: Milfredo
  Finding an element in a 1d list in a 2d array lionrocker221 0 722 Jun-27-2020, 04:50 PM
Last Post: lionrocker221
  Make an array of string number in a List polantas 5 1,213 May-27-2020, 07:18 AM
Last Post: buran
  List structure lost when multiplying Protonn 2 762 Apr-23-2020, 04:16 AM
Last Post: buran
  Transform list or set regardless of nesting structure blubb 2 777 Mar-10-2020, 07:17 PM
Last Post: ibreeden
  append list to empty array SchroedingersLion 1 1,040 Feb-02-2020, 05:29 PM
Last Post: SchroedingersLion
  Simple problem. looking for an efficient way silverchicken24 3 1,137 Oct-14-2019, 07:13 PM
Last Post: Larz60+

Forum Jump:

User Panel Messages

Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020