Learning Data Science Through The Python Data Science Handbook: NumPy Aggregations

StonedApe
4 min readApr 21, 2021

So today I read through the “Aggregations: Min, Max, and Everything in Between” portion of the NumPy section in the book, and luckily this one wasn’t that long or complicated.

This section was about how to use the numpy built in aggregation functions for working with arrays and extracting useful summary statistics and information.

Summing Array Values

As an example, I used a wine dataset to show how to use Numpy’s built in sum function.

Here, you can see that first I imported numpy obviously. I saved the dataset under the variable name “data”, and you can actually see how the first lines of information look in the dataset.

Then, I made an array for the different points each wine received and saved that array of information under variable name “points”.

Then you can see the point of this lesson, which is to show how effective the Numpy built in aggregate functions are.

You can see that Numpy’s version of the sum function np.sum(points), is much faster at running than the standard Python sum function, which you can see in the last line of code in the picture, sum(points).

--

--

StonedApe

A guy that smokes weed and learns stuff. Stay Trippy.