Introduction to NumPy
- 01:35
Learn what NumPy is, including NumPy arrays, functions for random sampling, and the foundation it provides for the Pandas package in Python.
Downloads
No associated resources to download.
Transcript
In this lesson, you're going to learn about one package that is absolutely critical for data science and machine learning, and it's called NumPy NumPy provides you with a new Python object called the NumPy array, and functions for random sampling, generating randomized data and setting random seeds. In addition, NumPy is the foundation of another package called Pandas that you're going to learn about in the next lesson. When using any package, the first step is always to import it into your Jupyter Notebook file. It's a good practice to always do this in your first cell. So let's go ahead and import NumPy.
Anytime I use a function inside an imported package, I first need to write the name of the package and then the name of the function. So it looks like this. For NumPy I'd say NumPy and then dot, and then the name of the function, whatever that is and then parentheses. In order to make that a little bit more convenient, since I'm gonna be writing this all the time, I can import that package with an alias. So an alias is just a nickname. I can say import NumPy as, what's common is using np, but you could make that A, B, C or 1, 2, 3, or whatever. Here we're just gonna say np.
So now I can say, instead of writing NumPy function, I can just write np function. So if you're gonna be writing that a hundred times in your code, it's useful to have an alias just to make things a little bit shorter and easier.