Python Forum

Full Version: Converting set of tuples to set of 2D numpy arrays
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
I have coded a function that returns a set of tuples, each tuple being of size 6, and assigned it to a var named tmp. Now I need to convert each tuple to a numpy array so I can reshape it into a 2x3 array.

With the code I've made however, I end up with a an array, that contains all of the 1D arrays from all the reshapes. But what I want is a collection (a list presumably) that contains each of the reshaped arrays separately so that I get each 2D array when I iterate through the collection.

This is the line of code I've made, but it doesn't wield the result I'm trying to get. And I just can't figure out how to do this.

Quote: coll = np.reshape((np.array(list(v for v in tmp))), (-1,3))