From the course: Data Analysis with Python and Pandas
Unlock this course with a free trial
Join today to access over 24,900 courses taught by industry experts.
Broadcasting
From the course: Data Analysis with Python and Pandas
Broadcasting
- [Instructor] Okay, so now that we've gotten familiar with the concept of vectorization, let's take a quick look at the concept of broadcasting. Broadcasting is what allows us to perform vectorized operations with arrays of different sizes where NumPy will expand the smaller array to quote unquote fit the larger one. And so the simplest example of this is looking at single values, also known as scalars which can be broadcast into arrays of any dimension. So let's say we have this three by three array. My first column has all ones, my second column has all twos, and my third column has all threes. If I add one to this array, one gets added to every element in this array. How does this code actually work behind the scenes? So we have our three by three array here. We're then going to add one. And what happens on the back end is that we fill out another three by three matrix and perform this matrix operation where we have this three by three matrix with 1, 2, 3's. And then we fill out a…
Practice while you learn with exercise files
Download the files the instructor uses to teach the course. Follow along and learn by watching, listening and practicing.
Contents
-
-
-
(Locked)
pandas and NumPy intro2m 53s
-
(Locked)
NumPy arrays and array properties7m 41s
-
(Locked)
Challenge: Array basics1m 47s
-
(Locked)
Solution: Array basics2m 2s
-
(Locked)
Array creation8m 13s
-
(Locked)
Random number generation5m 58s
-
(Locked)
Challenge: Array creation1m 30s
-
(Locked)
Solution: Array creation4m 22s
-
(Locked)
Indexing and slicing arrays9m 9s
-
(Locked)
Challenge: Indexing and slicing arrays1m 6s
-
(Locked)
Solution: Indexing and slicing arrays2m 23s
-
(Locked)
Array operations7m 45s
-
(Locked)
Challenge: Array operations2m 6s
-
(Locked)
Solution: Array operations4m 16s
-
(Locked)
Filtering arrays and modifying array values10m 56s
-
(Locked)
The where() function4m
-
(Locked)
Challenge: Filtering and modifying arrays1m 57s
-
(Locked)
Solution: Filtering and modifying arrays3m 11s
-
(Locked)
Array aggregation6m 51s
-
(Locked)
Array functions7m 41s
-
(Locked)
Sorting arrays3m 51s
-
(Locked)
Challenge: Aggregation and sorting1m 11s
-
(Locked)
Solution: Aggregation and sorting1m 35s
-
(Locked)
Vectorization4m 19s
-
(Locked)
Broadcasting7m 8s
-
(Locked)
Challenge: Bringing it all together2m 45s
-
(Locked)
Solution: Bringing it all together6m 18s
-
(Locked)
Key takeaways1m 56s
-
(Locked)
-
-
-
-
-
-
-
-
-