From the course: More Python Tips, Tricks, and Techniques for Data Science

Unlock the full course today

Join today to access over 22,600 courses taught by industry experts or purchase this course individually.

Broadcasting

Broadcasting - Python Tutorial

From the course: More Python Tips, Tricks, and Techniques for Data Science

Start my 1-month free trial

Broadcasting

- [Instructor] Now we'll discuss broadcasting, which is a very important topic that replaces the slow button loops and provides a means of vectorizing operations. A broadcasting is simply a set of rules for applying binary universal functions, like addition, subtraction, multiplication, division on arrays of different sizes. So, first off let's input the numpY library as np, around a cell. Now, if I try to add two arrays, let's say I create an aray, np.array using the array method, past the list elements three, four, five. Then I create another array b, using the same method. And then pass, let's say seven, eight, nine. And if I have to add these two arrays, I don't have to write any pattern loop. I can simply do a plus b and I have the results here. So the additional operation takes place on an element by element basis. So If have seven plus three, 10, eight plus four, 12, nine plus five 14. Now, when I have arrays…

Contents