Learning Data Science ThroughThe Python Data Science Handbook: NumPy UFuncs

StonedApe
7 min readApr 20, 2021

So since this is my first blog post regarding this topic, I should probably explain what I’m doing first.

For some time now, I’ve been meaning to go over this whole book (Python Data Science Handbook), but I just keep quitting after a certain amount of time, so I figured the one way to motivate me to continue on, is to basically tell the online world that I’m going to be doing this.

This book goes over all the basics of Data Science in 5 different sections. The first section is all about very basic Python stuff, like how to install the software and how to look up documentation, and very basic things like that. So I just skipped this first section to be honest.

I started right on section 2 of the book which is all about NumPy, but there are also 3 other sections on: Pandas, Matplotlib, and Machine Learning.

I did the first 2 parts of the Numpy section and posted them on Youtube under “Data Ape”, but I figured I’d just write about it instead, since no one really watches the videos anyway. And if there is someone that reads this, and wants me to post the other parts of this Numpy section, just let me know.

Anyways, back to todays lesson from the book which was all about ufuncs. This part was pretty damn long, but it had so much useful information in it.

UFuncs

This section on Numpy UFuncs starts by saying how Numpy is so important to the Python Data Science world because it provides “an easy and flexible interface to optimize computation with arrays of data”

However, the key to making Numpy computation fast, is to use vectorized operations, which are implemented through Numpy’s universal functions (ufuncs).

Vectorized operations are used to make repeated operations on array elements more efficient.

Numpy uses vectorized operations for many types of operations by performing an operation in an array, which will then be applied to each element of the array, which in turn will equal to much faster computation speed.

“Vectorized operations in NumPy are implemented via ufuncs, whose main purpose is to quickly execute repeated operations on values in NumPy arrays.”

Computation using vectorization is almost always more efficient than Python loops, especially as the arrays grow larger in size.

StonedApe

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