From the course: Python Data Analysis

Unlock the full course today

Join today to access over 23,000 courses taught by industry experts.

Doing math with NumPy arrays

Doing math with NumPy arrays - Python Tutorial

From the course: Python Data Analysis

Doing math with NumPy arrays

- [Instructor] NumPy is extremely useful in numerical calculations. That's because in addition to packing numbers efficient in memory, NumPy makes it easy to perform mathematical operations with entire arrays. For instance, in a study of mathematical functions, we may start with a vector of equally-spaced real values between say zero and five times pi. Here it is. Note that with the list space, the extreme of zero and five pi are included. Then we may want to complete the sine of all these values. We cannot do this with a function in the standard math library. Math dot sin. But we can with the NumPy version, which is called the universal function for this reason. It can operate on any array, in element by element fashion. There is always another NumPy array with the same shape as X. Using map dot lib, I can now plot sine X against X. Specifying first the coordinates along the horizontal axis and then the…

Contents