Learn Before
Concept

Broadcasting in array computations

When doing calculations using n-dimensional arrays you don't always need to initialize all elements to the same size, there are certain situations where python will broadcast the value into an array of the appropriate size. For example, if I want to add 20 to every element in my array I can just write

new_array = old_array + 20

and python will automatically create an appropriately sized array where all elements are equal to 100

For the complete list of broadcasting possibilities, see the reference link

0

1

Updated 2020-10-12

Tags

Data Science