Python Forum
Converting set of tuples to set of 2D numpy arrays
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Converting set of tuples to set of 2D numpy arrays
#1
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))
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  [Numpy] How to store different data type in one numpy array? water 7 288 Mar-26-2024, 02:18 PM
Last Post: snippsat
  Pandas dataframes and numpy arrays bytecrunch 1 1,292 Oct-11-2022, 08:08 PM
Last Post: Larz60+
  Numpy returns "TypeError: unsupported operand type(s) for *: 'numpy.ufunc' and 'int'" kalle 2 2,528 Jul-19-2022, 06:31 AM
Last Post: paul18fr
  comparing floating point arrays to arrays of integers in Numpy amjass12 0 1,613 Jul-26-2021, 11:58 AM
Last Post: amjass12
  converting dataframe to int numpy array glennford49 1 2,290 Apr-04-2020, 06:15 AM
Last Post: snippsat
  Corrupted numpy arrays when save to file. DreamingInsanity 2 3,183 Dec-14-2019, 12:12 PM
Last Post: DreamingInsanity
  Numpy arrays and compatability with Fortran arrays merrittr 0 1,849 Sep-03-2019, 03:54 AM
Last Post: merrittr
  "erlarge" a numpy-matrix to numpy-array PhysChem 2 2,927 Apr-09-2019, 04:54 PM
Last Post: PhysChem
  numpy subtraction of two arrays devenuro 1 11,685 Sep-24-2018, 12:55 AM
Last Post: Mekire

Forum Jump:

User Panel Messages

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