Ich habe ein ndarray wie folgt.Fügen Sie eine zusätzliche Spalte zu NDarray in Python
feature_matrix = [[0.1, 0.3], [0.7, 0.8], [0.8, 0.8]]
Ich habe eine Position ndarray wie folgt.
position = [10, 20, 30]
Jetzt möchte ich den Positionswert am Anfang der Feature-Matrix wie folgt hinzufügen.
[[10, 0.1, 0.3], [20, 0.7, 0.8], [30, 0.8, 0.8]]
habe ich versucht, die Antworten in dieser: How to add an extra column to an numpy array
E.g.,
feature_matrix = np.concatenate((feature_matrix, position), axis=1)
Allerdings bekomme ich den Fehler, dass zu sagen;
ValueError: all the input arrays must have same number of dimensions
Bitte helfen Sie mir dieses Problem zu lösen.
Verwenden Sie einfach 'np.column_stack'. – Divakar
Haben Sie versucht, meine Antwort an Ihre vorherige Frage anzupassen? 'np.insert (feature_matrix, 0, [10,20,30], ax is = 1)'; https://stackoverflow.com/questions/46065339/how-to-insert-list-of-tarray-lists-to-a-newndarray-in-python – hpaulj
Ja, ich bekomme SyntaxError: ungültiges Zeichen in Bezeichner. das kommt für den Achsenteil. –