Während ich das Spiel mit numpy,die dtype von numpy Array Wechsel wirkt sich auf die Daten
x = np.arange(9).reshape((3,3))
x
es array([[0, 1, 2],[3, 4, 5],[6, 7, 8]])
kehrt aber sobald ich den Datentyp ändern
vonx.dtype=np.int8
x
jetzt x wird array([[0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 2, 0, 0, 0, 0, 0,0, 0],[3, 0, 0, 0, 0, 0, 0, 0, 4, 0, 0, 0, 0, 0, 0, 0, 5, 0, 0, 0, 0, 0,0, 0],[6, 0, 0, 0, 0, 0, 0, 0, 7, 0, 0, 0, 0, 0, 0, 0, 8, 0, 0, 0, 0, 0,0, 0]], dtype=int8)
und x.shape
gibt zurück.
Warum passiert das?
Vielen Dank im Voraus!
Ich weiß nicht, warum das passiert ist, aber Sie wollen wahrscheinlich 'x.astype (np.int8)' – Akavall