简体   繁体   中英

Efficient way to assign list elements to numpy array

I have some numpy array objects in a list that I want to combine to a single numpy array. What is an efficient way to do this? The code below does not work since it puts a list into a numpy array...

import numpy as np


C = [np.array([1,2,3]), np.array([4,5,6]), np.array([7,8,9])]

M = np.zeros((1,3*3))

M[0] = C ## THIS THROWS AN ERROR

Use the following code

print(np.append(C,[]))

[1. 2. 3. 4. 5. 6. 7. 8. 9.]

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM