Bottom Page

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!

Top Page

Possibly Related Threads...
Thread Author Replies Views Last Post
  append list to empty array SchroedingersLion 1 126 Feb-02-2020, 05:29 PM
Last Post: SchroedingersLion
  how to make iterative search more efficient renergy 2 278 Jan-03-2020, 03:43 PM
Last Post: stullis
  Simple problem. looking for an efficient way silverchicken24 3 288 Oct-14-2019, 07:13 PM
Last Post: Larz60+
  How to read a text file into a list or an array musouka 2 517 Oct-07-2019, 01:54 PM
Last Post: musouka
  convert list of dict to dict of array of list with pop up kk230689 1 257 Sep-13-2019, 07:29 AM
Last Post: perfringo
  python3 List to array or string to extract data batchenr 4 597 May-28-2019, 01:44 PM
Last Post: buran
  Need help with reading input from stdin into array list Annie123 2 830 Mar-24-2019, 01:19 PM
Last Post: Annie123
  Copy List Structure leoahum 2 420 Mar-22-2019, 05:40 PM
Last Post: leoahum
  Most efficient way to define sub keys of a dictionary? wrybread 1 418 Feb-21-2019, 12:23 AM
Last Post: snippsat
  Efficient way of iterating a list of records anguis 4 532 Feb-19-2019, 03:39 AM
Last Post: scidam

Forum Jump:

Users browsing this thread: 1 Guest(s)