Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

Fill 2d array value in python with another 1d array per column

I have this code :

series =[]
list = type.groupby('level').size()

that list is equal = [20,40,40]

So, I want to have this loop:

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

series[0:3]=list

until here, its work but I want to have 2d matrix so I can save that list value for each loop.
matrixb=np.zeros((3,15))

for i in range (15):
    matrix[0:3][i]=series[0:3]

it does not work,
could not broadcast input array from shape (3,) into shape (15,)

>Solution :

You can’t perform such an assignment. You’d need to break them up as such:

for i in range (15):
    matrix[0][i] = series[0]
    matrix[1][i] = series[1]
    matrix[2][i] = series[2]    
Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading