NumPy and Pandas
00:11 NumPy is a popular scientific calculation library for Python. It is written using C-extensions, meaning the code is quite performant. This library does all sorts of mathy collection stuff, including multi-dimensional arrays and vectors.
It can also help you with your calculations, having features for linear algebra, Fourier transforms, and many of the other things that still haunt my nightmares from engineering school. NumPy is a third party library, and so you’ll need to use
pip to install it. As always with this kind of stuff, it’s best practice to use a virtualenv to do so. Let’s take a look at NumPy and the
len() function. First off, I’ll start with a single dimensional array.
len() … same result as with the 2D. What this is doing is returning the length of the first dimension, which in both the 2D and 3D examples was two. Using
.shape again, you can see the three dimensions, and
.ndim, or the length of the shape, and that gives you how many D your 3D is.
Another very common third-party library is Pandas. This one is for doing data crunching. It’s built on top of NumPy, so it is also quite speedy. Its key component is the
DataFrame object, which is a dictionary on steroids.
and there it is. Each list in the dictionary becomes a value in the row of the DataFrame. The
index property specifies the name of the row. Looking at the data itself, you can see Neo does everything well, Cypher needs to stay after school because his loyalty grade is … got some work to do. And here’s what you came for.
Become a Member to join the conversation.