Einführung in NumPy
Izzy Weber
Core Curriculum Manager, DataCamp




Broadcasting-taugliche Strukturen:
(10, 5) und (10, 1)(10, 5)
Nicht-Broadcasting-taugliche Strukturen:
(10, 5) und (5, 10)(10, 5) und (10, )
array = np.arange(10).reshape((2, 5))
array + np.array([0, 1, 2, 3, 4])
array([[ 0, 2, 4, 6, 8],
[ 5, 7, 9, 11, 13]])


array = np.arange(10).reshape((2, 5))
array + np.array([0, 1])
ValueError: operands could not be broadcast together with shapes (2,5) (2,)

array = np.arange(10).reshape((2, 5))
array + np.array([0, 1]).reshape((2, 1))
array([[ 0, 1, 2, 3, 4],
[ 6, 7, 8, 9, 10]])



Einführung in NumPy