Skip to content
Advertisement

how to split a list of numpy arrays and concatenate arrays of euch sublists in python

I have a list of numpy arrays and want to firstly split the list and then concatenate all the arrays exiting in each sublist. Number of sublists is defined by:

JavaScript

this is my list:

JavaScript

The length of all_data is 8 and it should be firstly modified to be a list of n_sublist lists. I mean two sublists which first one has the first four arrays and second one has the last four arrays. Then, all the arrays of each sublist should be concatenated. Finally, I want the following list as output:

JavaScript

I tried the following method but I was not successful to do so:

JavaScript

Advertisement

Answer

You can do:

JavaScript

Output:

JavaScript

Note for general number n_sublist:

JavaScript
User contributions licensed under: CC BY-SA
5 People found this is helpful
Advertisement