
Hey, and welcome to my course - Python NumPy For Your Grandma!
NumPy Version
I created this course using NumPy version 1.19.3, but if you're using a later version it should be fine for most (all?) of what I cover in this course.
IDE
You can use whatever IDE you prefer, but in this course I'm using Google Colab (colab.research.google.com). If you want to use Colab like me, check out my free tutorial on how to get up and running (youtube.com/watch?v=SUCRr56Jzkw).
In this video, you'll learn why NumPy arrays are useful and how they differ from a native Python list.
In this video, we'll cover basic properties and usage of NumPy arrays.
In this video, we'll look at different ways to create a NumPy array.
In this video, we'll see how to access and modify elements of a 1-D array.
In this video, we'll see how to access and modify elements of a multidimensional array.
In this video, we'll observe how basic math between arrays works.
Challenge
With your high school reunion fast approaching, you decide to get in shape and lose some weight. You record your weight every day for five weeks starting on a Monday. Given these daily weights, build an array with your average weight per weekend.
Challenge
After binge watching the discovery channel, you ditch your job as a trial lawyer to become a gold miner. You decide to prospect five locations underneath a 7x7 grid of land. How much gold do you uncover at each location?
Challenge
You decide to invest in a series of billboards along interstate 10 to advertise your stylish new chicken restaurant, Chic-fil-A. You buy three billboards evenly spaced starting from mile marker 17 and ending on mile marker 28. Then you buy another three billboards starting on mile marker 32 and ending on mile marker 36. In order, from mile marker 17 to 36, your billboards display these ads: A, B, C, C, B, A. Determine how far each "C" ad is from your restaurant which is located at mile marker 30.
In this video, we'll see how you can use broadcasting to combine arrays with different shapes.
In this video, we'll see how to use the newaxis keyword to increase the dimensionality of an array and why that's useful.
In this video, we'll see how to use the reshape function to change the shape of an array.
One of the most powerful features of NumPy is boolean indexing. In this video, we'll see how you can use an array of boolean values to index another array.
In this video, we'll see how you can use nan to represent missing or invalid values.
In this video, we'll see how you can represent infinite values in NumPy.
In this video, we’ll see how you can use NumPy's random module to shuffle arrays, sample values from arrays, and draw values from a host of probability distributions. And then we'll see why everything I just showed you is deprecated, and how to updated it to modern standards :)
Challenge
Eager to make your mark on the PTA, you decide the best way to hide eggs for for the upcoming easter egg hunt is to use NumPy. You represent the field as a 10x10 array of 0s. Now your goal is to insert twenty random normal values at random (non repeating) locations in the grid that tell you how much candy to hide at each spot and where.
In this video, we'll see how you can use NumPy's where function as a vectorized approach to writing if-else statements.
NumPy provides a variety of math functions like sum(), mean(), min(), max(), floor(), round(), exp(), log(), and countless others. When you understand how to use one of these functions, you'll understand how to use nearly all of them. So in this video, we're gonna dive into the sum() function, but everything we discuss will be applicable to a bunch of other math functions.
In this video we'll see how you can use the all() and any() functions to identify arrays where all or any of the elements match some condition.
In this video, we'll see how you can use the concatenate() function to combine two or more arrays.
In this video, we'll see how the functions hstack(), vstack(), and stack() are a lot like the concatenate() function with some subtle differences that can come in handy.
In this video, we'll see how you can use NumPy's sort() function to sort the elements of an array.
In this video, we'll see how to use the unique() function to get the unique elements of an array.
Challenge
You're given a 10x2 array of floats where each row represents a movie. The first column represents the movie's rating and the second column represents the director's rating. Your goal is to create a third column to represent the overall rating. The overall rating is equal to the movie rating if it exists, otherwise it's the director's rating.
Challenge
Ten fish occupy a 5x5x5 grid of water. Each fish decides to move to a new (i,j,k) location given by the matrix below. If multiple fish end up occupying the same cell, the biggest fish eats the smaller fish. Determine which fish will survive.
In this video, we'll take a deep dive into how array indexing works.
In this video, we'll shed some light on when array indexing produces a view and when it makes a copy.
Challenge
You're preparing for a game show where you play the following game: You're faced with four doors. Behind one door is cash money, and behind the other three doors is steaming pile of broccoli. If you pick the door with money, you get the option to play again at the risk of losing the money you've collected thus far. If you keep winning, you can play a maximum of three rounds before the game show host kicks you off his show.
You have some strategy ideas you'd like to evaluate before you go on the show. So you hired an unpaid intern to scour through historic recordings of the show and log data on where prizes were located and the value of each prize. Your intern gets back to you with the following matrices:
prize_doors: Here, element (i,j) gives the door hiding the prize in round j of the ith game
prizes: Here (i, j) gives the prize amount in round j of the ith game
Build a 5x3x4 matrix where (i,j,k) represents the prize behind door k of round j of game i.
Wanna learn NumPy?
Look no further. This course covers everything from how to install and import NumPy to how to solve complex problems involving array creation, transformations, and random sampling.
Course Structure
The course is presented as a series of on-demand lecture style videos with lots of animated examples, code walkthroughs, and challenge problems to test your knowledge. Go as fast or as slow as you want.
Philosophy
The course has a heavy emphasis on understanding NumPy, as opposed to rote memorization. ...But don't take my word for it. Check out the free lecture videos in the course curriculum below!