NumPy Arrays Workout
- 01:40
Learn how to import NumPy, and practice using NumPy Arrays.
Downloads
No associated resources to download.
Glossary
NumPy Numpy arrays PythonTranscript
Let's get some practice with NumPy arrays. In your Jupiter notebook start by importing NumPy if you haven't already with the alias np, and then recreate the following Excel table as a NumPy array. Once you've created the array, print it and then print the dimensions.
The first step, if you haven't done it already, is to import NumPy into your Jupyter Notebook.
Next, I'm gonna create a new array called array one, and then I'm gonna call the NumPy array function because the table that we're trying to replicate has three rows and two columns. This array is going to be a list of three lists with two objects each. So I'm gonna open square brackets for the big list, and then I'm gonna start my first list. Inside of that list, I'm gonna give it the integer one and two.
So that's my first row. My second row is gonna be a new list with three and four, and then my third row is going to be a new list with five and six.
And then I'm just gonna close that larger list that we're passing to the array and close my parentheses.
Now that I've defined array one, I'm going to print it, and then I'm gonna print a little spacer.
And finally, I'm going to print the shape of array one.