Wie füge ich eine neue Zeile zu einem leeren Nummernfeld hinzu?

Verwendung von standard-Python-arrays, kann ich Folgendes tun:

arr = []
arr.append([1,2,3])
arr.append([4,5,6])
# arr is now [[1,2,3],[4,5,6]]

Aber ich kann nicht die gleiche Sache in numpy. Zum Beispiel:

arr = np.array([])
arr = np.append(arr, np.array([1,2,3]))
arr = np.append(arr, np.array([4,5,6]))
# arr is now [1,2,3,4,5,6]

Ich schaute auch in vstackaber wenn ich vstack auf ein leeres array, erhalte ich:

ValueError: all the input array dimensions except for the concatenation axis must match exactly

So, wie kann ich tun, fügen Sie eine neue Zeile ein leeres array in numpy?

InformationsquelleAutor der Frage Tony Stark | 2014-03-13

Schreibe einen Kommentar